【问题标题】:How to create a copy of text file which is inside jar and extract the copy into a particular destination on my system?如何创建 jar 内的文本文件副本并将副本提取到我系统上的特定目标?
【发布时间】:2014-03-27 17:56:41
【问题描述】:

假设我在 jar Project.jar 中有 text.txt。如何创建 text.txt 的副本并将该副本提取到本地驱动器的特定文件夹中?

【问题讨论】:

    标签: java text jar extract


    【解决方案1】:

    尝试使用java.util.jar API。具体来说,看看JarFile.getEntry()JarFile.getInputStream()。例如:

    JarFile jarFile = new JarFile(new File("Project.jar"));
    ZipEntry entry = jarFile.getEntry("text.txt");
    InputStream is = jarFile.getInputStream(entry);
    // write InputStream to file
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-04
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 2011-10-02
      相关资源
      最近更新 更多