/** * Compresses a file into gzip archive. */ public static File gzip(String fileName) throws IOException { return gzip(new File(fileName)); }
/** * Compresses a file into gzip archive. */ public static File gzip(final String fileName) throws IOException { return gzip(new File(fileName)); }
/** * Locates gzipped version of bundle file. If gzip file * does not exist, it will be created. */ public File lookupGzipBundleFile(final File file) throws IOException { String path = file.getPath() + ZipUtil.GZIP_EXT; File gzipFile = new File(path); if (!gzipFile.exists()) { if (log.isDebugEnabled()) { log.debug("gzip bundle to " + path); } ZipUtil.gzip(file); } return gzipFile; }
@Test void testGzip() throws IOException { ZipUtil.gzip(new File(dataRoot, "sb.data")); File gzipFile = new File(dataRoot, "sb.data.gz"); assertTrue(gzipFile.exists()); FileUtil.move(gzipFile, new File(dataRoot, "sb2.data.gz")); ZipUtil.ungzip(new File(dataRoot, "sb2.data.gz")); File data = new File(dataRoot, "sb2.data"); assertTrue(data.exists()); byte[] data2Bytes = FileUtil.readBytes(data); byte[] data1Bytes = FileUtil.readBytes(new File(dataRoot, "sb.data")); assertTrue(Arrays.equals(data1Bytes, data2Bytes)); // cleanup FileUtil.delete(new File(dataRoot, "sb2.data")); FileUtil.delete(new File(dataRoot, "sb2.data.gz")); }
/** * Compresses a file into gzip archive. */ public static File gzip(final String fileName) throws IOException { return gzip(new File(fileName)); }
/** * Locates gzipped version of bundle file. If gzip file * does not exist, it will be created. */ public File lookupGzipBundleFile(File file) throws IOException { String path = file.getPath() + ZipUtil.GZIP_EXT; File gzipFile = new File(path); if (gzipFile.exists() == false) { if (log.isDebugEnabled()) { log.debug("gzip bundle to " + path); } ZipUtil.gzip(file); } return gzipFile; }
/** * Locates gzipped version of bundle file. If gzip file * does not exist, it will be created. */ public File lookupGzipBundleFile(final File file) throws IOException { String path = file.getPath() + ZipUtil.GZIP_EXT; File gzipFile = new File(path); if (!gzipFile.exists()) { if (log.isDebugEnabled()) { log.debug("gzip bundle to " + path); } ZipUtil.gzip(file); } return gzipFile; }