Friday, December 18, 2009

Re: [Java] getting a File from jar

 

jar equals zip, you can use org.apache.tools.zip.ZipFile to get the
object of the zip file(the jar file),
then get an iterator of wrapped files of the object, then you can get
file01.txt.

? 2009-5-1 18:30, Cristian Slav ??:
>
>
> Hi everybody,
>
> I am packing my program into a jar archive "program.jar".
> In it I have some directories which contains some files. something
> like this:
>
> program.jar/files/file01.txt
>
> How can I get a File class for reading my "file01.txt"?
> It is not useful for me if I read it as stream like this:
> getClass().getResourceAsStream("/files/file01.txt");
>
> I need to have something like
>
> File f = magicalFileFunction("/files/file01.txt");
>
> Is this possible?
>
> Thanks!
> Cristi
>
>

[Non-text portions of this message have been removed]

__._,_.___
Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELY
.

__,_._,___

No comments:

Post a Comment