title: Properly reading files with FileReader and BufferedReader in Java
body: <p>I am trying to learn how to use read files using FileReader in Java however I get persistent errors. I am using Eclipse and I get a red error indicating that The constructor FileReader(File) is 
  undefined and The constructor BufferedReader(FileReader) is undefined; however, I do not know where this error is originating from because I am using the right libraries and statements.</p>
  
  <p>I get the following error: </p>
  
  <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
      The constructor FileReader(File) is undefined
      The constructor BufferedReader(FileReader) is undefined
      at FileReader.main(FileReader.java:17)
  </code></pre>
  
  <p>My code is below:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.IOException;
  
  
  public class FileReader {
  
      public static void main(String[] args) {
  
          File file = new File("example.txt");
  
          BufferedReader br = null;
  
          try {
              FileReader fr = new FileReader(file);
              br = new BufferedReader(fr);
  
              String line;
  
              while( (line = br.readLine()) != null ) {
                  System.out.println(line);
              }
  
          } catch (FileNotFoundException e) {
              System.out.println("File not found: " + file.toString());
          } catch (IOException e) {
              System.out.println("Unable to read file: " + file.toString());
          }
          finally {
              try {
                  br.close();
              } catch (IOException e) {
                  System.out.println("Unable to close file: " + file.toString());
              }
              catch(NullPointerException ex) {
              }
          }
  
  
  
      }
  
  }
  </code></pre>
  
  <p>For extra context (Sorry about the size but I believe you can zoom in. You can see where to red errors are on the left of the line): 
  <img src="https://i.stack.imgur.com/fba09.png" alt="enter image description here"></p>