title: Issues using getResource() with txt file (Java)
body: <p>I have a setup in which I make use of a txt file (both reading and writing to it) in my program. At present I have it setup such that I use the local filepath on my machine, however I need to package it up into an executable JAR. To do this I've tried switching the filepath string over to the following:</p>
  
  <pre><code>String filepath = MyClass.class.getResource("/resources/textfile.txt");
  </code></pre>
  
  <p>However, when I run this I get a bunch of errors. After googling the method I found the similar method <code>getResourceAsStream</code> which I have also tried. This seems to return an InputStream object, however I need the filepath as a string ideally. Is this possible? If not what are my options?</p>
  
  <p><strong>Additional Info:</strong></p>
  
  <p>Here are the error messages I receive when trying to read &amp; write to the txt file:</p>
  
  <pre><code>java.io.FileNotFoundException:/Users/Fred/Documents/Eclipse%20Projects/RandomProject/bin/resources/textfile.txt (No such file or directory)
  </code></pre>