• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JarArchiveOutputStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FSIndex类代码示例发布时间:2022-05-23
下一篇:
Java FileSelectInfo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap