简体   繁体   English

访问 Jar 中的 .jpg 文件

[英]Accessing a .jpg file that is in a Jar

I have a question about accessing a.jpg file that is contained within a ant generated java jar file.我对访问 ant 生成的 java jar 文件中包含的 a.jpg 文件有疑问。 My java project contains Java code and some.jpg files that I use.我的 java 项目包含 Java 代码和我使用的一些.jpg 文件。 I want to be able to reference that.jpg file and be able to copy from jar to a directory.我希望能够引用那个.jpg 文件并能够从 jar 复制到一个目录。

Is there any way to that or do I always have to keep the jar outside of the jar file?有什么办法吗,还是我总是必须将 jar 保留在 jar 文件之外?

You can import the jar as a library into your project and access the resources directory or wherever you placed the JPG if you want to reference it directly from your project.您可以将 jar 作为库导入您的项目并访问资源目录或您放置 JPG 的任何位置(如果您想直接从您的项目中引用它)。

Jar files are just.zip's with a manifest. Jar 个文件只是带有清单的 .zip。 If you know where in the jar file the jpg is place, you just need to unzip the jar and copy the jpg to the desired location.如果您知道 jar 文件中 jpg 的位置,则只需解压缩 jar 并将 jpg 复制到所需位置即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM