?
Solved

Java Web Start and FileInputStream

Posted on 2004-08-04
3
Medium Priority
?
632 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 300 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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