title: Java Cannot find file?
body: <p>Hi I am trying to set up a scanner to print out contents of a text file. Here is my code:</p>
  
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;
  
  public class ScannerReadFile {
  
      public static void main(String[] args) {
  
          // Location of file to read
          File file = new File("CardNative.java.txt");
  
          try 
          {
  
                  Scanner scanner = new Scanner(file);
  
                  while (scanner.hasNextLine()) 
                  {
                      String line = scanner.nextLine();
                      System.out.println(line);
                  }
                  scanner.close();
          } 
          catch (FileNotFoundException e) 
          {
                e.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p>I have created a source folder in the project and put the text file in there. However I keep getting this error:</p>
  
  <pre><code>java.io.FileNotFoundException: CardNative.java.txt (The system cannot find the file specified)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:120)
      at java.util.Scanner.&lt;init&gt;(Scanner.java:636)
      at ScannerReadFile.main(ScannerReadFile.java:14)
  </code></pre>