jodd.io.ZipUtil.gzip()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(309)

本文整理了Java中jodd.io.ZipUtil.gzip()方法的一些代码示例,展示了ZipUtil.gzip()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil.gzip()方法的具体详情如下:
包路径:jodd.io.ZipUtil
类名称:ZipUtil
方法名:gzip

ZipUtil.gzip介绍

[英]Compresses a file into gzip archive.
[中]将文件压缩到gzip存档中。

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Compresses a file into gzip archive.
 */
public static File gzip(String fileName) throws IOException {
  return gzip(new File(fileName));
}

代码示例来源:origin: oblac/jodd

/**
 * Compresses a file into gzip archive.
 */
public static File gzip(final String fileName) throws IOException {
  return gzip(new File(fileName));
}

代码示例来源:origin: oblac/jodd

/**
 * 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;
}

代码示例来源:origin: oblac/jodd

@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"));
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Compresses a file into gzip archive.
 */
public static File gzip(final String fileName) throws IOException {
  return gzip(new File(fileName));
}

代码示例来源:origin: org.jodd/jodd-wot

/**
 * 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;
}

代码示例来源:origin: org.jodd/jodd-htmlstapler

/**
 * 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;
}

相关文章