• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Harshit Rastogi
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ?
 
Paul Clapham
Sheriff
Posts: 22505
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, to put it more simply, the file is in the root directory of the jar? Then...
 
Harshit Rastogi
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!