本文整理汇总了Java中org.apache.commons.compress.archivers.jar.JarArchiveOutputStream类的典型用法代码示例。如果您正苦于以下问题:Java JarArchiveOutputStream类的具体用法?Java JarArchiveOutputStream怎么用?Java JarArchiveOutputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JarArchiveOutputStream类属于org.apache.commons.compress.archivers.jar包,在下文中一共展示了JarArchiveOutputStream类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createJar
import org.apache.commons.compress.archivers.jar.JarArchiveOutputStream; //导入依赖的package包/类
/**
* Creates a JAR as a temporary file. Simple manifest file will automatically be inserted.
*
* @param entries files to put inside of the jar
* @return resulting jar file
* @throws IOException if any IO errors occur
* @throws NullPointerException if any argument is {@code null} or contains {@code null} elements
*/
public static File createJar(JarEntry... entries) throws IOException {
Validate.notNull(entries);
Validate.noNullElements(entries);
File tempFile = File.createTempFile(TestUtils.class.getSimpleName(), ".jar");
tempFile.deleteOnExit();
try (FileOutputStream fos = new FileOutputStream(tempFile);
JarArchiveOutputStream jaos = new JarArchiveOutputStream(fos)) {
writeJarEntry(jaos, MANIFEST_PATH, MANIFEST_TEXT.getBytes(Charsets.UTF_8));
for (JarEntry entry : entries) {
writeJarEntry(jaos, entry.name, entry.data);
}
}
return tempFile;
}
开发者ID:offbynull,项目名称:coroutines,代码行数:26,代码来源:TestUtils.java
示例2: copyFiles
import org.apache.commons.compress.archivers.jar.JarArchiveOutputStream; //导入依赖的package包/类
/** Copy all the files in a manifest from input to output. */
private static void copyFiles(Manifest manifest, JarFile in, JarArchiveOutputStream out, long timestamp)
throws IOException {
final byte[] buffer = new byte[4096];
int num;
final Map<String, Attributes> entries = manifest.getEntries();
final List<String> names = new ArrayList<>(entries.keySet());
Collections.sort(names);
for (final String name : names) {
final JarEntry inEntry = in.getJarEntry(name);
if (inEntry.getMethod() == JarArchiveEntry.STORED) {
// Preserve the STORED method of the input entry.
out.putArchiveEntry(new JarArchiveEntry(inEntry));
} else {
// Create a new entry so that the compressed len is recomputed.
final JarArchiveEntry je = new JarArchiveEntry(name);
je.setTime(timestamp);
out.putArchiveEntry(je);
}
final InputStream data = in.getInputStream(inEntry);
while ((num = data.read(buffer)) > 0) {
out.write(buffer, 0, num);
}
out.flush();
out.closeArchiveEntry();
}
}
开发者ID:jrummyapps,项目名称:BusyBox,代码行数:30,代码来源:ZipSigner.java
示例3: createJar
import org.apache.commons.compress.archivers.jar.JarArchiveOutputStream; //导入依赖的package包/类
/**
* Recursively create JAR archive from directory
*/
public static void createJar(File path, String root, OutputStream os) throws IOException {
log.debug("createJar({}, {}, {})", new Object[]{path, root, os});
if (path.exists() && path.canRead()) {
JarArchiveOutputStream jaos = new JarArchiveOutputStream(os);
jaos.setComment("Generated by OpenKM");
jaos.setCreateUnicodeExtraFields(UnicodeExtraFieldPolicy.ALWAYS);
jaos.setUseLanguageEncodingFlag(true);
jaos.setFallbackToUTF8(true);
jaos.setEncoding("UTF-8");
// Prevents java.util.jar.JarException: JAR file must have at least one entry
JarArchiveEntry jae = new JarArchiveEntry(root + "/");
jaos.putArchiveEntry(jae);
jaos.closeArchiveEntry();
createJarHelper(path, jaos, root);
jaos.flush();
jaos.finish();
jaos.close();
} else {
throw new IOException("Can't access " + path);
}
log.debug("createJar: void");
}
开发者ID:openkm,项目名称:document-management-system,代码行数:31,代码来源:ArchiveUtils.java
示例4: createArchiveOutputStream
import org.apache.commons.compress.archivers.jar.JarArchiveOutputStream; //导入依赖的package包/类
ArchiveOutputStream createArchiveOutputStream() throws IOException {
switch (format) {
case CPIO:
return new CpioArchiveOutputStream(output);
case JAR:
return new JarArchiveOutputStream(output);
case TAR:
return new TarArchiveOutputStream(output);
case ZIP:
return new ZipArchiveOutputStream(output);
}
// Normally, this code is not called because of the above switch.
throw new IOException("Format is configured.");
}
开发者ID:hata,项目名称:embulk-encoder-commons-compress,代码行数:16,代码来源:CommonsCompressArchiveProvider.java
示例5: makeArchiveOutputStream
import org.apache.commons.compress.archivers.jar.JarArchiveOutputStream; //导入依赖的package包/类
@Override
public ArchiveOutputStream makeArchiveOutputStream(OutputStream stream)
throws IOException, ArchiveException {
JarArchiveOutputStream jaos = new JarArchiveOutputStream(stream);
jaos.setLevel(_compressionLevel);
jaos.setUseZip64(Zip64Mode.AsNeeded);
jaos.setFallbackToUTF8(true);
return jaos;
}
开发者ID:turbolocust,项目名称:GZipper,代码行数:10,代码来源:Jar.java
示例6: writeJarEntry
import org.apache.commons.compress.archivers.jar.JarArchiveOutputStream; //导入依赖的package包/类
private static void writeJarEntry(JarArchiveOutputStream jaos, String name, byte[] data) throws IOException {
ZipArchiveEntry entry = new JarArchiveEntry(name);
entry.setSize(data.length);
jaos.putArchiveEntry(entry);
jaos.write(data);
jaos.closeArchiveEntry();
}
开发者ID:offbynull,项目名称:coroutines,代码行数:8,代码来源:TestUtils.java
示例7: ProcessAction
import org.apache.commons.compress.archivers.jar.JarArchiveOutputStream; //导入依赖的package包/类
public ProcessAction(@Nonnull JarArchiveOutputStream zipOutStr) {
this.zipOutStr = zipOutStr;
}
开发者ID:shevek,项目名称:jarjar,代码行数:4,代码来源:JarjarCopyAction.java
注:本文中的org.apache.commons.compress.archivers.jar.JarArchiveOutputStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论