Q:

Reading a text file from a jar

I'm having trouble reading a text file from inside a jar. I managed it while it was unzipped but now that I've archived it it won't work.
The jar has:

BTA.jar

Splash.class
*.class
Splash.txt
etc..

Now, at the moment I'm using a BufferedReader and a FileReader
 f = new FileReader("Splash.txt");
 in = new BufferedReader(f);

but from googling around I know that that only reads files from outside of the jar.
My question is: How do I read a file from inside the jar?

A:

Assuming you're executing the BTA.jar, you can use
InputStream in = YourClass.class.getResourceAsStream("/Splash.txt");

to retrieve an InputStream and pass it to the BufferedReader through an InputStreamReader.
The rules for the format of the path to pass to the method are defined here, in the javadoc for the Class class.

