• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

Problem with applet accessing text files in its jar file

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
asswasp
Asked:
asswasp
  • 3
  • 2
1 Solution
 
CEHJCommented:
What is held in 'filename'?
0
 
asswaspAuthor Commented:
Just a string like "alan.txt"
0
 
CEHJCommented:
Try

"/alan.txt"

0
 
asswaspAuthor Commented:
Thank you.
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now