Solved

Java Web Start and FileInputStream

Posted on 2004-08-04
3
588 Views
Last Modified: 2008-02-01
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?
0
Comment
Question by:beside
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 100 total points
ID: 11716027
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
 

Author Comment

by:beside
ID: 11724002
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
 
LVL 35

Expert Comment

by:TimYates
ID: 11724049
:-)

Glad you got it sorted :-)

Good luck with it!

Tim
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now