gpt4 book ai didi

com.thoughtworks.go.util.ZipUtil.zipContentsOfMultipleFolders()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 18:54:49 27 4
gpt4 key购买 nike

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

ZipUtil.zipContentsOfMultipleFolders介绍

暂无

代码示例

代码示例来源: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");
}

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

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

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