Solved

Problem with applet accessing text files in its jar file

Posted on 2003-11-24
5
244 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
[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
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
Html Table Looping (part 2) 5 35
jsp error 6 45
American Express @Work site and Java 4 64
What is the use of Forwarding Class in java 1 34
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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

756 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