title: Cannot open file for reading
body: <p>I am using console IO to read file and display it in my IDE window ( I am using Netbeanz) </p>
  
  <pre><code>package javaapplication1;
  import java.util.*;
  import java.io.*;
  
  public class JavaApplication1
  {
      public static void main(String[] args) throws FileNotFoundException
      {  
         String data;
         Scanner myscan = new Scanner(new File("foo.txt"));
  
         while ( myscan.hasNextLine())
         {
             data = myscan.nextLine();
             System.out.println(data);
         }
  
         myscan.close();
      }
  }
  </code></pre>
  
  <p>For some reason , i cannot open the file : <code>foo.txt</code> though i have placed it in the same folder as my application </p>
  
  <p>Here is a picture of where i have placed <code>foo.txt</code></p>
  
  <p><img src="https://i.stack.imgur.com/q24Ze.png" alt="enter image description here"></p>
  
  <p>I get the following exception</p>
  
  <pre><code>Exception in thread "main" java.io.FileNotFoundException: foo.txt (The system cannot find the file specified)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:138)
      at java.util.Scanner.&lt;init&gt;(Scanner.java:656)
      at javaapplication1.JavaApplication1.main(JavaApplication1.java:21)
  </code></pre>
  
  <p><strong>How do i resolve this problem and what is happening ??</strong></p>