title: How to use BufferedReader in a try catch?
body: <p>I've been trying to use bufferedreader several times but every time I get some form error. This is time it is "not a statement" and "; expected" also "catch without try". I keep getting errors at the line with the try(bufferedreader) line. Am I using this correct? I am just trying it out and not quite sure how it works. from the online resource I've been looking at my code looks fine. But when I run my own it gives me errors.</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  
  
  public class Problem2 {
      public static void main(String [] args) {
          if(args.length != 1){
              System.out.println("Please enter a txt file");
          }
          else{
              String s;
              try (BufferedReader br = new BufferedReader(New FileReader(args[0]))) {
                  while ( (s = br.readLine()) != null) {
                      String[] words = s.split("[^a-zA-Z0-9]+");
                      for(int i = 0; i &lt; words.length; i++){
                          //code
                          }
                      }
                  }
                  br.close();
              }
              catch (FileNotFoundException ex){
                  System.out.println(ex);
              }
              catch (IOException ex){
                  System.out.println(ex);
              }
          }
      }
  }
  </code></pre>