title: Scanner class java file not found
body: <p>Scanner Class couldnt find the file
  I use NetBeansIDE, and the test.txt is in the folder path: D:\netbeans project works\ReadFile\src\readfile\test.txt </p>
  
  <p>in the same folder the readfile.java exsist.
  the code is as below.
  It generates file not found.</p>
  
  <pre><code>package readfile;
  
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.util.Scanner;
  
  
  public class ReadFile {
  
      public static void main(String[] args) throws IOException , FileNotFoundException 
      {  
          Scanner scanner = new Scanner(new File("test.txt"));  
  
          while (scanner.hasNextLine())  
              System.out.println(scanner.nextLine());  
      }  
  }
  </code></pre>
  
  <p>output:-</p>
  
  <pre><code>run:
  Exception in thread "main" java.io.FileNotFoundException: test.txt (The system cannot find the file specified)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:106)
      at java.util.Scanner.&lt;init&gt;(Scanner.java:636)
      at readfile.ReadFile.main(ReadFile.java:14)
  Java Result: 1
  BUILD SUCCESSFUL (total time: 0 seconds)
  </code></pre>