title: How to read a text file from a web application
body: <p>I am writing a Jersey Restful service to be deployed on Tomcat via a war file.</p>
  
  <p>The service needs to read data in 3 text files. The text files need to exist on the file system or read from the classpath. I have tried to read the data from the file system and classpath but neither are working. I would be happy with either way - it doesn't matter.</p>
  
  <p>If it was to use the following code,can someone tell me where to place the text file specified  so that the code picks up the file?</p>
  
  <pre><code>BufferedReader br = new BufferedReader(new InputStreamReader
  (this.getClass().getClassLoader().getResourceAsStream("myfile.txt")));
  </code></pre>
  
  <p>I am getting a null pointer exception.</p>
  
  <p>If I was to read the file from the file system, use the following code, where do I place the files in my Jar?</p>
  
  <pre><code>FileInputStream fs = new FileInputStream("myFile.txt");
  DataInputStream is = new DataInputStream(fs);
  BufferedReader br = new BufferedReader(new InputStreamReader(is));
  </code></pre>
  
  <p>I am getting a FileNotFound exception.</p>
  
  <p>Any suggestions are welcome.</p>