gpt4 book ai didi

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

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

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

ZipUtil.zip介绍

[英]Zips a file or a folder. If adding a folder, all its content will be added.
[中]打开文件或文件夹的拉链。如果添加文件夹,将添加其所有内容。

代码示例

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

@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 testZipDir() throws IOException {
  ZipUtil.zip(new File(dataRoot));
  File zipFile = new File(dataRoot + ".zip");
  assertTrue(zipFile.exists());
  int directoryCount = 0;
  try (ZipFile zipfile = new ZipFile(zipFile)) {
    for (Enumeration<? extends ZipEntry> entries = zipfile.entries(); entries.hasMoreElements(); ) {
      ZipEntry zipEntry = entries.nextElement();
      if (zipEntry.isDirectory()) {
        directoryCount++;
        assertTrue(zipEntry.getName().equals("data/") || zipEntry.getName().equals("data/file/"));
      }
    }
  }
  assertEquals(2, directoryCount);
  // cleanup
  FileUtil.delete(zipFile);
}

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

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

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