• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading file from jar file

 
Gail Schlentz
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read a file that I'm using as a template. The template file is in the deployed jar file for my application. I'm thinking my syntax for reading a file from a jar file is incorrect, though I've tried several examples I've found, and none seem to work.

Here's my code snippet:




And here's the relevent output & error:



I've searched online & it seems that I'm doing it right. But obviously I'm not! I've tried making the slashes go the other way, tried finding other files in that same directory (also unsuccessful), opened up my jar file to verify that my template file is at the path I'm looking at. To no avail.

Any ideas?? :-)
 
Paul Clapham
Sheriff
Posts: 20988
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resources inside jar files aren't "files". Only things on disks that your operating system manages as files are "files". So you can't use a FileInputStream. Do this instead:
 
Gail Schlentz
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh. <duh>

Thank you very much!!! :-D
 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thannks very much... the exact answer which i confused...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic