/** * Checks if the signature matches what is expected for a jar file * (in this case it is the same as for a zip file). * * @param signature * the bytes to check * @param length * the number of bytes to check * @return true, if this stream is a jar archive stream, false otherwise */ public static boolean matches(final byte[] signature, final int length ) { return ZipArchiveInputStream.matches(signature, length); } }
if (ZipArchiveInputStream.matches(signature, signatureLength)) { return ZIP; } else if (JarArchiveInputStream.matches(signature, signatureLength)) {
/** * Checks if the signature matches what is expected for a jar file * (in this case it is the same as for a zip file). * * @param signature * the bytes to check * @param length * the number of bytes to check * @return true, if this stream is a jar archive stream, false otherwise */ public static boolean matches(final byte[] signature, final int length ) { return ZipArchiveInputStream.matches(signature, length); } }
@Override public boolean matches(byte[] signature, int signatureLength) { return ZipArchiveInputStream.matches(signature, signatureLength); }
@Override public boolean matches(byte[] signature, int signatureLength) { return ZipArchiveInputStream.matches(signature, signatureLength); }
private Boolean isZip(InputStream stream) throws IOException { if (!stream.markSupported()) { // ZIP by default return null; } final byte[] signature = new byte[12]; stream.mark(signature.length); int signatureLength = stream.read(signature); stream.reset(); return ZipArchiveInputStream.matches(signature, signatureLength); } }
public static boolean isZip(File file) throws IOException { final byte[] signature = new byte[12]; FileInputStream stream = new FileInputStream(file); stream.mark(signature.length); int signatureLength = stream.read(signature); stream.close(); return ZipArchiveInputStream.matches(signature, signatureLength); }
public static boolean isZip(File file) throws IOException { final byte[] signature = new byte[12]; int signatureLength; try (FileInputStream stream = new FileInputStream(file)) { stream.mark(signature.length); signatureLength = stream.read(signature); } return ZipArchiveInputStream.matches(signature, signatureLength); }
if (ZipArchiveInputStream.matches(signature, signatureLength)) { return ZIP; } else if (JarArchiveInputStream.matches(signature, signatureLength)) {