title: java: Using Buffered Reader and checking if String is null
body: <p>why doesn´t <code>if (txtLine == null)   {    break;     };</code>work? or maybe the correct answer is why does it still set the string <code>txtLine</code> to null (literally). The way I understand it, it should break the moment the string is null? I don´t want it to set the string to "null". but stop when there are no more lines in the *.txt file</p>
  
  <pre><code>try{
      BufferedReader txtReader = new BufferedReader (new FileReader ("test.txt"));
      while (true) {
          // Reads one line.
          println(txtLine);
          if(txtLine == null){
              break;
          };
          txtLine = txtReader.readLine();
          nLines(txtLine);
      }
      txtReader.close();
  } catch (IOException ex) {
      throw new ErrorException(ex);   
  }
  </code></pre>
  
  <p>the <code>txtFile</code> variable is defined as an IVAR</p>
  
  <pre><code>private int nChars = 0;
  private String txtLine = new String(); 
  private ArrayList &lt;String&gt; array = new ArrayList &lt;String&gt;();
  </code></pre>