Hi I am sort of new to java and am trying to extract a string from a .txt file.
 BufferedReader br = new BufferedReader(new FileReader("file.txt"));
    try {
      StringBuilder sb = new StringBuilder();
      String line = br.readLine();
        while (line != null) {
        sb.append(line);
        sb.append(System.lineSeparator());
        line = br.readLine();
      }
      String everything = sb.toString();
    } 
    catch(IOException e) 
    {  
    }
    finally {
      br.close();
    }
my issue is that
when I compile this i get an error message --> cannot find symbol symbol : method lineSeparator() location: class java.lang.System. This error message does not occur when i try to compile the line with a different method from the System class.
When I try to comment off this line to see if the rest works smoothly, I get another error message --> unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown. Any explanation for how to fix my issue with not being able to access this method and/or how to get rid of the second error message would be appreciated.