本文整理了Java中jodd.io.ZipUtil.zip()
方法的一些代码示例,展示了ZipUtil.zip()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil.zip()
方法的具体详情如下:
包路径:jodd.io.ZipUtil
类名称: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));
}
内容来源于网络,如有侵权,请联系作者删除!