本文整理了Java中com.thoughtworks.go.util.ZipBuilder
类的一些代码示例,展示了ZipBuilder
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipBuilder
类的具体详情如下:
包路径:com.thoughtworks.go.util.ZipBuilder
类名称:ZipBuilder
暂无
代码示例来源:origin: gocd/gocd
private void zipContents(File file, OutputStream output, int level, boolean excludeRootDir) throws IOException {
new ZipBuilder(this, level, output, excludeRootDir).add("", file).done();
}
代码示例来源:origin: gocd/gocd
public File done() throws IOException {
ZipBuilder zipBuilder = zipUtil.zipContentsOfMultipleFolders(pluginsZipFile, true);
zipBuilder.add("bundled", bundledPluginsDir).add("external", externalPluginsDir).add("dummy.txt", dummyFileSoZipFileIsNotEmpty).done();
return pluginsZipFile;
}
}
代码示例来源:origin: gocd/gocd
public ZipBuilder zipContentsOfMultipleFolders(File destZipFile, boolean excludeRootDir) throws IOException {
return new ZipBuilder(this, 0, new FileOutputStream(destZipFile), excludeRootDir);
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldZipMultipleFolderContentsWhenNotExcludingRootDirectory() throws IOException {
File folderOne = temporaryFolder.newFolder("folder1");
FileUtils.writeStringToFile(new File(folderOne, "folder1-file1.txt"), "folder1-file1", UTF_8);
FileUtils.writeStringToFile(new File(folderOne, "folder1-file2.txt"), "folder1-file2", UTF_8);
File folderTwo = temporaryFolder.newFolder("folder2");
FileUtils.writeStringToFile(new File(folderTwo, "folder2-file1.txt"), "folder2-file1", UTF_8);
FileUtils.writeStringToFile(new File(folderTwo, "folder2-file2.txt"), "folder2-file2", UTF_8);
File targetZipFile = temporaryFolder.newFile("final2.zip");
ZipBuilder zipBuilder = zipUtil.zipContentsOfMultipleFolders(targetZipFile, false);
zipBuilder.add("folder-one", folderOne);
zipBuilder.add("folder-two", folderTwo);
zipBuilder.done();
assertContent(targetZipFile, "folder-one/folder1/folder1-file1.txt", "folder1-file1");
assertContent(targetZipFile, "folder-one/folder1/folder1-file2.txt", "folder1-file2");
assertContent(targetZipFile, "folder-two/folder2/folder2-file1.txt", "folder2-file1");
assertContent(targetZipFile, "folder-two/folder2/folder2-file2.txt", "folder2-file2");
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldZipMultipleFolderContentsAndExcludeRootDirectory() throws IOException {
File folderOne = temporaryFolder.newFolder("a-folder1");
FileUtils.writeStringToFile(new File(folderOne, "folder1-file1.txt"), "folder1-file1", UTF_8);
FileUtils.writeStringToFile(new File(folderOne, "folder1-file2.txt"), "folder1-file2", UTF_8);
File folderTwo = temporaryFolder.newFolder("a-folder2");
FileUtils.writeStringToFile(new File(folderTwo, "folder2-file1.txt"), "folder2-file1", UTF_8);
FileUtils.writeStringToFile(new File(folderTwo, "folder2-file2.txt"), "folder2-file2", UTF_8);
File targetZipFile = temporaryFolder.newFile("final1.zip");
ZipBuilder zipBuilder = zipUtil.zipContentsOfMultipleFolders(targetZipFile, true);
zipBuilder.add("folder-one", folderOne);
zipBuilder.add("folder-two", folderTwo);
zipBuilder.done();
assertContent(targetZipFile, "folder-one/folder1-file1.txt", "folder1-file1");
assertContent(targetZipFile, "folder-one/folder1-file2.txt", "folder1-file2");
assertContent(targetZipFile, "folder-two/folder2-file1.txt", "folder2-file1");
assertContent(targetZipFile, "folder-two/folder2-file2.txt", "folder2-file2");
}
内容来源于网络,如有侵权,请联系作者删除!