title: How to detect new line(or empty line) in a file?
body: <p>I'm trying to write a program, which reads text from a file that is specified by the user. Now, this program should detect an empty line.</p>
  
  <p>This is what I have unsuccessfully tried:</p>
  
  <pre><code>public static void editFile(String filePath) throws FileNotFoundException, IOException {
      file = new File(filePath);
      if(file.exists()) {
          fileRead = new FileReader(file);
  
          bufferedReader = new BufferedReader(fileRead);
  
          String line = bufferedReader.readLine();
          System.out.println(line);
          while(line != null) {
              line = bufferedReader.readLine();
              if(line == "") {
                  //line = null;
                  System.out.println("a");
              }
              System.out.println(line);
          }
      }
  }
  </code></pre>
  
  <p>To be more clear:</p>
  
  <p>If I'm passing in a text file with for example this text:</p>
  
  <blockquote>
    <p>test1<br />
       test2<br />
       <br />
       test3<br />
       <br />
       test4<br /></p>
  </blockquote>
  
  <p>it should print 2 a's in the console because of the empty spaces, but it doesn't.</p>
  
  <p>Thank you for your time, I am glad for any suggestion you may have.</p>