title: Where to put a textfile I want to use in eclipse?
body: <p>I need to read a text file when I start my program. I'm using eclipse and started a new java project. In my project folder I got the "src" folder and the standard "JRE System Library" + staedteliste.txt... I just don't know where to put the text file. I literally tried every folder I could think off....I cannot use a "hard coded" path because the text file needs to be included with my app...</p>
  
  <p>I use the following code to read the file, but I get this error:</p>
  
  <pre><code>Error:java.io.FileNotFoundException:staedteliste.txt(No such file or directory)
  </code></pre>
  
  <hr>
  
  <pre><code>public class Test {
  
  ArrayList&lt;String[]&gt; values;
  
  public static void main(String[] args) {
      // TODO Auto-generated method stub
  
      URL url = Test.class.getClassLoader().getResource("src/mjb/staedteliste.txt");
      System.out.println(url.getPath()); // I get a nullpointerexception here!
      loadList();
  }
  
  public static void loadList() {
      BufferedReader reader;
      String zeile = null;
  
      try {
          reader = new BufferedReader(new FileReader("src/mjb/staedteliste.txt"));
          zeile = reader.readLine();          
  
          ArrayList&lt;String[]&gt; values = new ArrayList&lt;String[]&gt;();
  
          while (zeile != null) {             
              values.add(zeile.split(";"));
              zeile = reader.readLine();
          }
          System.out.println(values.size());
          System.out.println(zeile);
  
      } catch (IOException e) {
          System.err.println("Error :"+e);
      }
  }
  </code></pre>
  
  <p>}</p>