• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing files in a jar

 
ravinderSingh singh
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
 
ravinderSingh singh
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Its possible to keep the 'file' and the .class file in the same .jar file.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic