aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Storing files in a jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Storing files in a jar" Watch "Storing files in a jar" New topic
Author

Storing files in a jar

ravinderSingh singh
Ranch Hand

Joined: Nov 18, 2004
Posts: 41
When a file has been packaged within a JAR, how can you access it using a File or FileInputStream as you cannot specify the path ie. you can't do c:\\somefile.txt as the file in stored within a JAR?

Thanks
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

http://java.sun.com/j2se/1.3/docs/api/java/util/jar/JarInputStream.html


Groovy
ravinderSingh singh
Ranch Hand

Joined: Nov 18, 2004
Posts: 41
Thank you.

What do you do when both the class doing the reading and the file to be read are stored in the same JAR file? For example,

ClassOne.java - File which performs the read operation
README.txt - File to be read

Both are deployed in MyJar.jar
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by ravinderSingh singh:
Thank you.

What do you do when both the class doing the reading and the file to be read are stored in the same JAR file? For example,

ClassOne.java - File which performs the read operation
README.txt - File to be read

Both are deployed in MyJar.jar


I dont think it is possible to read a file in the same jar file.
:roll:
Sreenivasa Majji
Ranch Hand

Joined: Jul 12, 2001
Posts: 224
Yes. Its possible to keep the 'file' and the .class file in the same .jar file.


Sreenivasa Majji
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by Sreenivasa Majji:
Yes. Its possible to keep the 'file' and the .class file in the same .jar file.


This was not what the poster wants to know. He has already said that the file and .class are in the same jar. He wants to read the file from the .class without requiring the path to jar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing files in a jar