List of utility methods to do Zip File Check
boolean | isZip(BufferedInputStream in) Test for ZIP stream signature. in.mark(4); byte[] b = new byte[4]; byte[] zipSig = new byte[4]; zipSig[0] = 0x50; zipSig[1] = 0x4b; zipSig[2] = 0x03; zipSig[3] = 0x04; try { ... |
boolean | isZip(byte[] bytes) is Zip return Byte.compare(bytes[0], (byte) 0x50) == 0 && Byte.compare(bytes[1], (byte) 0x4B) == 0; |
boolean | isZip(File candidate) Checks if is zip (extension == zip). return candidate.getName().toLowerCase().endsWith(".zip"); |
boolean | isZip(File f) is Zip return f.getName().endsWith(".zip"); |
boolean | isZip(File file) is Zip return existsWithExtension(file, ".zip"); |
boolean | isZip(File file) is Zip try (FileInputStream inputStream = new FileInputStream(file)) { return new ZipInputStream(inputStream).getNextEntry() != null; } catch (IOException e) { throw new RuntimeException("Problem to check if file " + file.getPath() + " is a zip", e); |
boolean | isZip(File file) is Zip if (file.isDirectory()) { return false; if (!file.canRead()) { return false; if (file.length() < 4) { return false; ... |
boolean | isZip(File file) is Zip if (file.exists() == false) return false; try (InputStream in = new FileInputStream(file); ZipInputStream zipIn = new ZipInputStream(in)) { ZipEntry e = zipIn.getNextEntry(); if (e == null) return false; int ctr = 0; while (e != null && ctr < 4) { ... |
boolean | isZip(File zip) Check to see if the file is a zip file. The ZIP file format can be determined by detecting #MAGIC_BYTES at the start of the zip file. byte[] buffer = new byte[MAGIC_BYTES.length]; if (zip == null) throw new NullPointerException("Zip file is null"); assert zip != null; if (zip.isDirectory()) return false; InputStream in = new DataInputStream(new FileInputStream(zip)); in.read(buffer); ... |
boolean | isZip64EndOfCentralDirectoryLocatorPresent(RandomAccessFile zip, long zipEndOfCentralDirectoryPosition) Returns true if the provided file contains a ZIP64 End of Central Directory Locator. long locatorPosition = zipEndOfCentralDirectoryPosition - ZIP64_EOCD_LOCATOR_SIZE; if (locatorPosition < 0) { return false; zip.seek(locatorPosition); return zip.readInt() == ZIP64_EOCD_LOCATOR_SIG_REVERSE_BYTE_ORDER; |