title: reading a file in Java, it does not find the file
body: <p>I have coded the following for reading a txt in Java:</p>
  
  <pre><code>public static void main(String[] args) throws FileNotFoundException, IOException {
      // TODO code application logic here
      String name;
      String line;
      System.out.println("Input file name");
      Scanner inp=new Scanner(System.in);
      name=inp.nextLine();  
      FileReader file=new FileReader(name);
      BufferedReader br=new BufferedReader(new FileReader(name));
      while((line=br.readLine())!=null){
          System.out.println(br.readLine());
      }
      br.close();
  }
  </code></pre>
  
  <p>I have a txt file that is under the same folder of my java code, its name is data.txt (which contains a list of numbers line by line), the problem that I got is that when I run this I got the following message:</p>
  
  <pre><code>Exception in thread "main" java.io.FileNotFoundException: data.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.io.FileInputStream.&lt;init&gt;(FileInputStream.java:97)
  </code></pre>
  
  <p>where is the mistake? also how I can surround it with a try catch block in case the file does not exist?</p>
  
  <p>I have put the <code>System.out.println(new File(name).getAbsoluteFile);</code> and it appears all the path thru data.txt, but I want to point by default to my current folder; should I use <code>Scanner</code>?</p>