Solved

Problem with applet accessing text files in its jar file

Posted on 2003-11-24
5
242 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 88
Error in @AspectJ Based AOP with Spring 2 13
jboss wildfly 10.1 10 85
How to convert from xls to xlsx using java 7 39
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.

776 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