Solved

Problem with applet accessing text files in its jar file

Posted on 2003-11-24
5
239 Views
Last Modified: 2010-03-31
I have an applet that uses 4 text files. I want to put it all together in a jar file and upload it to my site. But I'm having problems accessing the text files I've put inside the jar file. The error is a NullPointerException on the line:
InputStream dataStream = getClass().getResource(filename).openStream();
in the FlatFile.java class.

Can anyone suggest a solution for how to achieve what I want?
0
Comment
Question by:asswasp
  • 3
  • 2
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 9811459
What is held in 'filename'?
0
 

Author Comment

by:asswasp
ID: 9811477
Just a string like "alan.txt"
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 9811493
Try

"/alan.txt"

0
 

Author Comment

by:asswasp
ID: 9811672
Thank you.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9811695
:-)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

760 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

20 Experts available now in Live!

Get 1:1 Help Now