This tip shows how to read a text file from a jar.

[ReadFromJar.java]

 import java.applet.*;
import java.io.*;

public class ReadFromJar extends Applet{

  public void init(){
    readTextFromJar("datafile1.txt"); 
    readTextFromJar("test/datafile2.txt");  
    }

  public void readTextFromJar(String s) {
    String thisLine;
    try {
      InputStream is = getClass().getResourceAsStream(s);
      BufferedReader br = new BufferedReader
         (new InputStreamReader(is));
      while ((thisLine = br.readLine()) != null) {  
         System.out.println(thisLine);
         }
      }
    catch (Exception e) {
      e.printStackTrace();
      }
  }
}

Create 2 datafiles.

datafile1.txt in the same directory as ReadfromJar.class and datafile2.txt in a subdirectory called test

[datafile1.txt]
datafile1  line 1
datafile1  line 2
datafile1  line 3
datafile1  line 4
datafile1  line 5

[test\datafile2.txt]
datafile2  line 1
datafile2  line 2
datafile2  line 3
datafile2  line 4
datafile2  line 5

Create the jar with

 jar cf readjar.jar ReadFromJar.class datafile1.txt test\datafile2.txt

Try with the follwing HTML page

 <HTML><HEAD></HEAD><BODY>
<APPLET CODE=ReadFromJar.class width=1 height=1 archive=readjar.jar>
</APPLET>
See java console for output</BODY></HTML>