Java Web Start and FileInputStream

Hello,

I want to open file from within java web start jar file.

I tryied to use FileInputStream, like this:

FileInputStream storefilestream = new FileInputStream(keystore);

but java throws exception that file not found, but it's in main jar file from where I'm loading web start application.

How can I open file from jar file?
besideAsked:
Who is Participating?
 
TimYatesCommented:
this.getClass().getResourceAsStream( keystore ) ;

should do it...  (keystore should be a path relative to this class, or the root of the jar file this class is in)
0
 
besideAuthor Commented:
This way I can't get file stream from jar file.. i used instead

this.getClassLoader().getResourceAsStream( keystore );

this works O.K. for me.

But anyway thank you for showing the right way.
0
 
TimYatesCommented:
:-)

Glad you got it sorted :-)

Good luck with it!

Tim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.