- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.thoughtworks.go.util.ZipUtil
类的一些代码示例,展示了ZipUtil
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil
类的具体详情如下:
包路径:com.thoughtworks.go.util.ZipUtil
类名称:ZipUtil
暂无
代码示例来源:origin: gocd/gocd
void explodePluginJarToBundleDir(File file, File location) {
try {
wipePluginBundleDirectory(location);
ZipUtil zipUtil = new ZipUtil();
zipUtil.unzip(file, location);
} catch (IOException e) {
throw new RuntimeException(String.format("Failed to copy plugin jar %s to bundle location %s", file, location), e);
}
}
代码示例来源:origin: gocd/gocd
private void setOutput(boolean needToZip, File file, HttpServletResponse response) throws IOException {
ServletOutputStream out = response.getOutputStream();
if (needToZip) {
new ZipUtil().zip(file, out, Deflater.NO_COMPRESSION);
} else {
IOUtils.copy(new FileInputStream(file), out);
}
out.flush();
}
代码示例来源:origin: gocd/gocd
private boolean shouldReplaceBundledPlugins(File bundledPluginsDirectory) throws IOException {
File versionFile = new File(bundledPluginsDirectory, "version.txt");
if (!versionFile.exists()) return true;
String currentlyInstalledVersion = FileUtils.readFileToString(versionFile, UTF_8);
String versionNumberInZip = zipUtil.getFileContentInsideZip(getPluginsZipStream(), "version.txt");
return !currentlyInstalledVersion.equals(versionNumberInZip);
}
代码示例来源:origin: gocd/gocd
@Autowired
public AnalyticsPluginAssetsService(AnalyticsExtension analyticsExtension, AnalyticsMetadataLoader metadataLoader) {
this.zipUtil = new ZipUtil();
this.analyticsExtension = analyticsExtension;
this.pluginAssetPaths = new HashMap<>();
metadataLoader.registerListeners(this);
metadataStore = AnalyticsMetadataStore.instance();
}
代码示例来源:origin: gocd/gocd
public void unzip(File zip, File destDir) throws IOException {
unzip(new ZipInputStream(new BufferedInputStream(new FileInputStream(zip))), destDir);
}
代码示例来源:origin: gocd/gocd
@Test
@RunIf(value = OSChecker.class, arguments = OSChecker.LINUX)
public void shouldZipFileWhoseNameHasSpecialCharactersOnLinux() throws IOException {
File specialFile = new File(srcDir, "$`#?@!()?-_{}^'~.+=[];,a.txt");
FileUtils.writeStringToFile(specialFile, "specialFile", UTF_8);
zipFile = zipUtil.zip(srcDir, temporaryFolder.newFile(), Deflater.NO_COMPRESSION);
zipUtil.unzip(zipFile, destDir);
File baseDir = new File(destDir, srcDir.getName());
File actualSpecialFile = new File(baseDir, specialFile.getName());
assertThat(actualSpecialFile.isFile(), is(true));
assertThat(fileContent(actualSpecialFile), is(fileContent(specialFile)));
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldZipFileContentsOnly() throws IOException {
zipFile = zipUtil.zipFolderContents(srcDir, temporaryFolder.newFile(), Deflater.NO_COMPRESSION);
assertThat(zipFile.isFile(), is(true));
zipUtil.unzip(zipFile, destDir);
assertIsDirectory(new File(destDir, emptyDir.getName()));
assertIsDirectory(new File(destDir, childDir1.getName()));
File actual1 = new File(destDir, file1.getName());
assertThat(actual1.isFile(), is(true));
assertThat(fileContent(actual1), is(fileContent(file1)));
File actual2 = new File(destDir, childDir1.getName() + File.separator + file2.getName());
assertThat(actual2.isFile(), is(true));
assertThat(fileContent(actual2), is(fileContent(file2)));
}
代码示例来源:origin: gocd/gocd
@Override void createCachedFile(ArtifactFolder artifactFolder) throws IOException {
File originalFolder = artifactFolder.getRootFolder();
File cachedZip = cachedFile(artifactFolder);
File cachedTempZip = zipToTempFile(cachedZip);
cachedTempZip.getParentFile().mkdirs();
try {
zipUtil.zip(originalFolder, cachedTempZip, Deflater.DEFAULT_COMPRESSION);
} catch (IOException e) {
cachedTempZip.delete();
throw e;
}
FileUtils.moveFile(cachedTempZip, cachedZip);
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldReadContentsOfAFileWhichIsInsideAZip() throws Exception {
FileUtils.writeStringToFile(new File(srcDir, "some-file.txt"), "some-text-here", UTF_8);
zipFile = zipUtil.zip(srcDir, temporaryFolder.newFile(), Deflater.NO_COMPRESSION);
String someStuff = zipUtil.getFileContentInsideZip(new ZipInputStream(new FileInputStream(zipFile)), "some-file.txt");
assertThat(someStuff, is("some-text-here"));
}
代码示例来源: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
public void zipFolderContents(File destDir, File destZipFile) throws IOException {
zipFolderContents(destDir, destZipFile, Deflater.BEST_SPEED);
}
代码示例来源:origin: gocd/gocd
public GoArtifactsManipulatorStub(List<Property> properties, List<String> consoleOuts, HttpService service) {
super(service, new URLService(), new ZipUtil());
this.properties = properties;
this.consoleOuts = consoleOuts;
}
代码示例来源:origin: gocd/gocd
void usePackagedCommandRepository(ZipInputStream zipInputStream, File defaultDirectory) throws IOException {
FileUtil.deleteDirectoryNoisily(defaultDirectory);
zipUtil.unzip(zipInputStream, defaultDirectory);
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldZipFileContentsAndUnzipIt() throws IOException {
zipFile = zipUtil.zip(srcDir, temporaryFolder.newFile(), Deflater.NO_COMPRESSION);
assertThat(zipFile.isFile(), is(true));
zipUtil.unzip(zipFile, destDir);
File baseDir = new File(destDir, srcDir.getName());
assertIsDirectory(new File(baseDir, emptyDir.getName()));
assertIsDirectory(new File(baseDir, childDir1.getName()));
File actual1 = new File(baseDir, file1.getName());
assertThat(actual1.isFile(), is(true));
assertThat(fileContent(actual1), is(fileContent(file1)));
File actual2 = new File(baseDir, childDir1.getName() + File.separator + file2.getName());
assertThat(actual2.isFile(), is(true));
assertThat(fileContent(actual2), is(fileContent(file2)));
}
代码示例来源:origin: gocd/gocd
@Test
public void shouldPreserveFileTimestampWhileGeneratingTheZipFile() throws Exception {
File file = temporaryFolder.newFile("foo.txt");
file.setLastModified(1297989100000L); // Set this to any date in the past which is greater than the epoch
File zip = zipUtil.zip(file, temporaryFolder.newFile("foo.zip"), Deflater.DEFAULT_COMPRESSION);
ZipFile actualZip = new ZipFile(zip.getAbsolutePath());
ZipEntry entry = actualZip.getEntry(file.getName());
assertThat(entry.getTime(), is(file.lastModified()));
}
代码示例来源: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 void handle(InputStream stream) throws IOException {
ZipInputStream zipInputStream = new ZipInputStream(stream);
LOG.info("[Agent Fetch Artifact] Downloading from '{}' to '{}'. Will read from Socket stream to compute MD5 and write to file", srcFile, destOnAgent.getAbsolutePath());
long before = System.currentTimeMillis();
new ZipUtil((entry, stream1) -> {
LOG.info("[Agent Fetch Artifact] Downloading a directory from '{}' to '{}'. Handling the entry: '{}'", srcFile, destOnAgent.getAbsolutePath(), entry.getName());
new ChecksumValidator(artifactMd5Checksums).validate(getSrcFilePath(entry), md5Hex(stream1), checksumValidationPublisher);
}).unzip(zipInputStream, destOnAgent);
LOG.info("[Agent Fetch Artifact] Downloading a directory from '{}' to '{}'. Took: {}ms", srcFile, destOnAgent.getAbsolutePath(), System.currentTimeMillis() - before);
}
代码示例来源:origin: gocd/gocd
private File createZip(String subDirectoryName) throws IOException {
File first = new File(artifactDest, "first");
FileUtils.writeStringToFile(first, "First File", UTF_8);
File second = new File(artifactDest, subDirectoryName + "/second");
FileUtils.writeStringToFile(second, "Second File", UTF_8);
new ZipUtil().zip(artifactDest, zip, 0);
return zip;
}
代码示例来源:origin: gocd/gocd
public GoArtifactsManipulatorStub(HttpService service) {
super(service, new URLService(), new ZipUtil());
properties = new ArrayList<>();
consoleOuts = new ArrayList<>();
}
代码示例来源:origin: gocd/gocd
public boolean saveFile(File dest, InputStream stream, boolean shouldUnzip, int attempt) {
String destPath = dest.getAbsolutePath();
try {
LOGGER.trace("Saving file [{}]", destPath);
if (shouldUnzip) {
zipUtil.unzip(new ZipInputStream(stream), dest);
} else {
systemService.streamToFile(stream, dest);
}
LOGGER.trace("File [{}] saved.", destPath);
return true;
} catch (IOException e) {
final String message = format("Failed to save the file to: [%s]", destPath);
if (attempt < GoConstants.PUBLISH_MAX_RETRIES) {
LOGGER.warn(message, e);
} else {
LOGGER.error(message, e);
}
return false;
} catch (IllegalPathException e) {
final String message = format("Failed to save the file to: [%s]", destPath);
LOGGER.error(message, e);
return false;
}
}
我在这个网站上发布的代码有这个问题 https://developers.google.com/drive/quickstart-cs是 Google Drive 快速入门的开发人员站点。我按照网站上
我正在尝试制作一个非常简单的 Kafka Producer,目前正在关注 producer example除了我的制作人没有分区程序类。 将所需文件导出到 jar 后,我将它们传输到我的 Linux
问题 在java中,我有一个“Util项目”,在进行单元测试时使用另一个“Mock项目”。 我的问题是“模拟项目”也使用“Util项目”来构建一些模拟对象。 当我使用 Maven 构建项目时,我无法构
据我所知,这些包已经存在很长时间了。但是,我从未见过它们的实际用法。而且这些包似乎不成熟,不再维护。如果是,为什么这些包现在存在? 最佳答案 包裹automata被 scala.xml.dtd 使用,
关闭。这个问题需要debugging details .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 1年前关闭。 Improve this question Co
在java.util.Collections中,有一个方法: public static void fill(List list, T obj) 用第二个参数指定的对象填充第一个参数指定的List。
我不明白它要我做什么。分配给 sentence正在工作: val sentences : java.util.List[CoreMap] = document.get(classOf[Sentence
在我的 React 应用程序中,我想使用一些实用程序。我见过两种不同的方法。第一个是,只是创建函数并将其导出。第二个是,创建一个 Util 类并导出一个对象,这样它就不能被实例化(静态类)。 clas
我有一个 util 类,它接受 String jwtToken 和 Key key 并使用 io.jsonwebtoken.jwts 解码 jwt。 但是,我无法对此进行测试。原因是,我无法模拟公钥并
我有使用目标命名空间的专有架构 xmlns:ax216="http://util.java/xsd" 这给我带来了从 java (java.util.xsd) 开始生成禁止的(由 Java 安全管理器
我正在阅读集合以查看 Javadocs 中的实现层次结构。 Collections声明为public class Collections extendds Object Collection声明为pu
我正在使用 Spring-boot 应用程序,我可以在其中连接 Azure 应用程序配置。但是当我尝试使用内容类型应用程序/JSON 读取值时出现错误。 我的Java类 @ConfigurationP
我正在使用 Spring-boot 应用程序,我可以在其中连接 Azure 应用程序配置。但是当我尝试使用内容类型应用程序/JSON 读取值时出现错误。 我的Java类 @ConfigurationP
我在使用格式说明符时遇到问题。这是否意味着我正在使用 %d? public static void main(String[] args) { double y, x; for (x =
鉴于此代码 import java.util.Iterator; private static List someList = new ArrayList(); public static void
我正在 HackerEarth 解决问题,我无法弄清楚为什么我的程序在命令行上正确运行并给出正确的结果,但在代码编辑器上运行时却给出 java.util.NoSuchElementException
我正在尝试使用以下代码使用对象列表列表中的数据填充tableModel readExcel.readSheet(0): TableModel tableModel = new DefaultTabl
java.util.Set 、 java.util.List 和其他 Collection 接口(interface)不可序列化。需要一个简单、直接的解决方案来在可序列化的 POJO 中使用它。 pu
我试图从 servlet 返回数据库搜索结果的 ArrayList 以显示在 jsp 页面上。 在servlet中设置arraylist作为请求的属性,并将请求转发到jsp页面。当我尝试在 jsp 页
我是android新手,最近我试图从firebase中提取数据到recyclerview/cardview中以垂直布局显示数据,它显示将Hashmap转换为Arraylist的错误,其中代码是:
我是一名优秀的程序员,十分优秀!