本文整理了Java中org.apache.tools.ant.taskdefs.Jar.zipDir()
方法的一些代码示例,展示了Jar.zipDir()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.zipDir()
方法的具体详情如下:
包路径:org.apache.tools.ant.taskdefs.Jar
类名称:Jar
方法名:zipDir
暂无
代码示例来源:origin: org.apache.ant/ant
private void writeManifest(ZipOutputStream zOut, Manifest manifest)
throws IOException {
StreamUtils.enumerationAsStream(manifest.getWarnings())
.forEach(warning -> log("Manifest warning: " + warning, Project.MSG_WARN));
zipDir((Resource) null, zOut, "META-INF/", ZipFileSet.DEFAULT_DIR_MODE,
JAR_MARKER);
// time to write the manifest
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(baos, Manifest.JAR_ENCODING);
PrintWriter writer = new PrintWriter(osw);
manifest.write(writer, flattenClassPaths);
if (writer.checkError()) {
throw new IOException("Encountered an error writing the manifest");
}
writer.close();
ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
try {
super.zipFile(bais, zOut, MANIFEST_NAME,
System.currentTimeMillis(), null,
ZipFileSet.DEFAULT_FILE_MODE);
} finally {
// not really required
FileUtils.close(bais);
}
super.initZipOutputStream(zOut);
}
代码示例来源:origin: org.sonatype.plugins/jarjar-maven-plugin
private void addParentDirs(String file, ZipOutputStream zOut) throws IOException {
int slash = file.lastIndexOf('/');
if (slash >= 0) {
String dir = file.substring(0, slash);
if (dirs.add(dir)) {
addParentDirs(dir, zOut);
super.zipDir((File) null, zOut, dir + "/", ZipFileSet.DEFAULT_DIR_MODE, JAR_MARKER);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!