ZipUtils { public static boolean isZipFile(File file) throws IOException { if (file.isDirectory()) { return false; } final byte[] bytes = new byte[4]; try (FileInputStream fIn = new FileInputStream(file)) { if (fIn.read(bytes) != bytes.length) { return false; } } ByteBuffer zipFileHeaderSignature = ByteBuffer.wrap(bytes); zipFileHeaderSignature.order(ByteOrder.LITTLE_ENDIAN); return 0x04034b50 == zipFileHeaderSignature.getInt(); } private  ZipUtils(); static ZipOutputStream stream(Path zip); static void add(ZipOutputStream out, Path f); static void add(ZipOutputStream out, Path f, Path rootPath); static Collection<String> listEntries(File zip); static Collection<String> listEntries(InputStream in); static void unzip(File zip, File targetDir); static void unzip(InputStream in, File targetDir); static void getResources(ZipFile zip, Pattern filter, Consumer<InputStream> consumer); static boolean isZipFile(File file);  }
@Test public void shouldBeAbleToDetectZipFile() throws IOException { Assert.assertTrue(ZipUtils.isZipFile(zipFile)); }