aspose file tools
The moose likes Beginning Java and the fly likes How to read a file from a java class, both are in the same jar Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How to read a file from a java class, both are in the same jar" Watch "How to read a file from a java class, both are in the same jar" New topic
Author

How to read a file from a java class, both are in the same jar

Harshit Rastogi
Ranch Hand

Joined: Apr 15, 2008
Posts: 131

I have following structure in jar

myjar.jar -> com -> MYProgram.class
-> file.txt


The file.txt is inside the myjarar.jar and parallel to com folder..
In MYProgram i am trying to do:


I am getting NullpointerException when i try to read the inputstream..

Where is it going wrong ?


<a href="http://technologiquepanorama.wordpress.com" target="_blank" rel="nofollow">My Techie Blog</a><br /><a href="http://www.java-questions.com" target="_blank" rel="nofollow">Java Questions</a>
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

Or, to put it more simply, the file is in the root directory of the jar? Then...
Harshit Rastogi
Ranch Hand

Joined: Apr 15, 2008
Posts: 131
Paul Clapham wrote:Or, to put it more simply, the file is in the root directory of the jar? Then...


yes it worked. the file is already in the root. thnx
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to read a file from a java class, both are in the same jar
 
Similar Threads
Need help with binding. tags for composite.xml files
Reading In A Resource Folder
JavaScript not loading
Problem With Algorithm Involving Recursion and String Manipulation
how to print values on jsp page fetched from servlet