gpt4 book ai didi

jodd.io.ZipUtil类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 23:16:03 26 4
gpt4 key购买 nike

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

ZipUtil介绍

[英]Performs zip/gzip/zlib operations on files and directories. These are just tools over existing java.util.zip classes, meaning that existing behavior and bugs are persisted. Most common issue is not being able to use UTF8 in file names, because implementation uses old ZIP format that supports only IBM Code Page 437. This bug was resolved in JDK7: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4244499
[中]对文件和目录执行zip/gzip/zlib操作。这些只是现有java.util.zip类之上的工具,这意味着现有的行为和bug会被持久化。最常见的问题是不能在文件名中使用UTF8,因为实现使用了只支持IBM代码页437的旧ZIP格式。这个错误在JDK7中得到了解决:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4244499

代码示例

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

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

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

/**
 * Decompress gzip archive.
 */
public static File ungzip(String file) throws IOException {
  return ungzip(new File(file));
}

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

/**
 * Extracts zip file content to the target directory.
 * @see #unzip(java.io.File, java.io.File, String...)
 */
public static void unzip(String zipFile, String destDir, String... patterns) throws IOException {
  unzip(new File(zipFile), new File(destDir), patterns);
}

代码示例来源: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: redisson/redisson

/**
   * Stores the content into the ZIP.
   */
  public ZipBuilder save() throws IOException {
    ZipUtil.addToZip(zos, file, path, comment, recursive);
    return ZipBuilder.this;
  }
}

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

/**
 * Zips a file or a folder.
 * @see #zip(java.io.File)
 */
public static File zip(String file) throws IOException {
  return zip(new File(file));
}

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

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

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

close(zip);

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

public ZipBuilder addFolder(String folderName) throws IOException {
  ZipUtil.addFolderToZip(zos, folderName, null);
  return this;
}

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

/**
   * Stores the content into the ZIP.
   */
  public ZipBuilder save() throws IOException {
    ZipUtil.addToZip(zos, bytes, path, comment);
    return ZipBuilder.this;
  }
}

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

/**
 * Zips a file or a folder.
 * @see #zip(java.io.File)
 */
public static File zip(final String file) throws IOException {
  return zip(new File(file));
}

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

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

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

close(zip);

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

public ZipBuilder addFolder(final String folderName) throws IOException {
  ZipUtil.addFolderToZip(zos, folderName, null);
  return this;
}

代码示例来源: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

/**
 * Decompress gzip archive.
 */
public static File ungzip(final String file) throws IOException {
  return ungzip(new File(file));
}

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

/**
   * Stores the content into the ZIP.
   */
  public ZipBuilder save() throws IOException {
    ZipUtil.addToZip(zos, bytes, path, comment);
    return ZipBuilder.this;
  }
}

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

/**
 * Extracts zip file content to the target directory.
 * @see #unzip(java.io.File, java.io.File, String...)
 */
public static void unzip(final String zipFile, final String destDir, final String... patterns) throws IOException {
  unzip(new File(zipFile), new File(destDir), patterns);
}

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

@Test
void testZip() throws IOException {
  ZipUtil.zip(new File(dataRoot, "sb.data"));
  File zipFile = new File(dataRoot, "sb.data.zip");
  assertTrue(zipFile.exists());
  // cleanup
  FileUtil.delete(zipFile);
  ZipUtil.zip(new File(dataRoot, "file"));
  zipFile = new File(dataRoot, "file.zip");
  assertTrue(zipFile.exists());
  // cleanup
  FileUtil.delete(zipFile);
}

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

@Test
void testZlib() throws IOException {
  ZipUtil.zlib(new File(dataRoot, "sb.data"));
  File zlibFile = new File(dataRoot, "sb.data.zlib");
  assertTrue(zlibFile.exists());
  // cleanup
  FileUtil.delete(zlibFile);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com