简体   繁体   中英

read a file a jar

Is it possible to read a file within a jar ?

My project structure look like this:

Root:

 ->src

 ->lib -<my.jar>

In the lib directory there is a jar(my.jar) that contain text file

This is the class path in the manifest file: Class-Path: ./lib/my.jar

and i am trying to load the text file like this:

 InputStream in = MyClass.class.getResourceAsStream("/text.license");

Any idea how to read the file ?

Thanks

http://docs.oracle.com/javase/6/docs/api/java/util/jar/JarFile.html

Your best bet would to use the JarFile class (handles zip compression)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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