title: (line != null) not working in Java BufferedReader
body: <p>I'm programming a java program that reads from file and I need it to stop at the end of the file, I remember using "While(line != null)" in the past, to take every line in the text, however, it's not working for me right now. My method is this:</p>
  
  <pre><code>int contator = 0;
  String line2 = "";
  while (line2 != null) {
              line2 = reader2.readLine();
              fi[contator]=line2;
              for(int i =0;i&lt;ret.length;i++){
                  System.out.println("line2 : "+line2+"ret : "+ret[i]);
                  if(line2.toLowerCase().contains(ret[i])){
                      fi[contator] = line2;
                      etiqueta[contator]=etiqueta[contator]+" reti";
                  }   
              }contator ++;
           }
  </code></pre>
  
  <p>It's working, I see the prints right, but when it has to end, prints the last line with null, and exits with the "java.lang.NullPointerException"; printing</p>
  
  <pre><code>line2 : Number of words ret : 361.
  line2 : Something here ret : 369.
  line2 : other things ret : 379.23
  line2 : nullret : 250.5//this is the problem, after this it throws exception
  </code></pre>
  
  <p><strong>I tried other methods like:</strong></p>
  
  <pre><code>while (line2 != "null" )
  while (line2.length()&gt;0)
  while (!line2.isEmpty)
  </code></pre>
  
  <p>Nothing worked, I'm on Eclipse IDE Mars.2; any idea?
  Thanks in advance.</p>