title: Reading file using java
body: <p>I'm trying to read a txt file using this code.</p>
  
  <p>This is my function which reads the file:</p>
  
  <pre><code>public class Open_File {        
      public void fct(File file) throws IOException {    
          String line = null;
          FileReader fr = null;
          {
              try
              {
                  fr = new FileReader( file );
              } 
              catch (FileNotFoundException e) 
              {  
                  System.out.println( "File doesn't exists" );
                  e.printStackTrace();
              }
              BufferedReader br = new BufferedReader( fr );
  
              try
              {
                  while( (line = br.readLine()) != null )
                  {
                      System.out.println( line );
                  }
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              finally{
                  br.close();
              }
          }
      }
  }
  </code></pre>
  
  <p>And this is my main function, where I give the path: </p>
  
  <pre><code>public static void main(String[] args) throws IOException {
      Open_File o = null;
      File file= new File("C:/test.txt");
      o.fct(file);
      System.out.println("réussi");
  }
  </code></pre>
  
  <p>The problem is that the execution throws a <code>NullPointerException</code></p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at test.main(test.java:17)
  </code></pre>
  
  <p>Please could anyone give me a solution for this problem.</p>