title: Read from file in eclipse
body: <p>I'm trying to read from a text file to input data to my java program. However, eclipse continuosly gives me a Source not found error no matter where I put the file.</p>
  
  <p>I've made an additional sources folder in the project directory, the file in question is in both it and the bin file for the project and it still can't find it. </p>
  
  <p>I even put a copy of it on my desktop and tried pointing eclipse there when it asked me to browse for the source lookup path.</p>
  
  <p>No matter what I do it can't find the file.</p>
  
  <p>here's my code in case it's pertinent:</p>
  
  <pre><code>System.out.println(System.getProperty("user.dir"));
      File file = new File("file.txt");
  
  
      Scanner scanner = new Scanner(file);
  </code></pre>
  
  <p>in addition, it says the user directory is the project directory and there is a copy there too.</p>
  
  <p>I have no clue what to do.</p>
  
  <p>Thanks,
  Alex</p>
  
  <p>after attempting the suggestion below and refreshing again, I was greeted by a host of errors.</p>
  
  <pre><code>FileNotFoundException(Throwable).&lt;init&gt;(String) line: 195   
  FileNotFoundException(Exception).&lt;init&gt;(String) line: not available 
  FileNotFoundException(IOException).&lt;init&gt;(String) line: not available   
  FileNotFoundException.&lt;init&gt;(String) line: not available    
  URLClassPath$JarLoader.getJarFile(URL) line: not available  
  URLClassPath$JarLoader.access$600(URLClassPath$JarLoader, URL) line: not available  
  URLClassPath$JarLoader$1.run() line: not available  
  AccessController.doPrivileged(PrivilegedExceptionAction&lt;T&gt;) line: not available [native method] 
  URLClassPath$JarLoader.ensureOpen() line: not available 
  URLClassPath$JarLoader.&lt;init&gt;(URL, URLStreamHandler, HashMap) line: not available   
  URLClassPath$3.run() line: not available    
  AccessController.doPrivileged(PrivilegedExceptionAction&lt;T&gt;) line: not available [native method] 
  URLClassPath.getLoader(URL) line: not available 
  URLClassPath.getLoader(int) line: not available 
  URLClassPath.access$000(URLClassPath, int) line: not available  
  URLClassPath$2.next() line: not available   
  URLClassPath$2.hasMoreElements() line: not available    
  ClassLoader$2.hasMoreElements() line: not available 
  CompoundEnumeration&lt;E&gt;.next() line: not available   
  CompoundEnumeration&lt;E&gt;.hasMoreElements() line: not available    
  ServiceLoader$LazyIterator.hasNext() line: not available    
  ServiceLoader$1.hasNext() line: not available   
  LocaleServiceProviderPool$1.run() line: not available   
  AccessController.doPrivileged(PrivilegedExceptionAction&lt;T&gt;) line: not available [native method] 
  LocaleServiceProviderPool.&lt;init&gt;(Class&lt;LocaleServiceProvider&gt;) line: not available  
  LocaleServiceProviderPool.getPool(Class&lt;LocaleServiceProvider&gt;) line: not available 
  NumberFormat.getInstance(Locale, int) line: not available   
  NumberFormat.getNumberInstance(Locale) line: not available  
  Scanner.useLocale(Locale) line: not available   
  Scanner.&lt;init&gt;(Readable, Pattern) line: not available   
  Scanner.&lt;init&gt;(ReadableByteChannel) line: not available 
  Scanner.&lt;init&gt;(File) line: not available    
  </code></pre>
  
  <p>code used:</p>
  
  <pre><code>System.out.println(System.getProperty("user.dir"));
      File file = new File(System.getProperty("user.dir") + "/file.txt");
  
  
      Scanner scanner = new Scanner(file);
  </code></pre>