title: Reading lines with BufferedReader and checking for end of file
body: <p>If I have something like this in my code:</p>
  
  <pre><code>String line = r.readLine();  //Where r is a bufferedReader
  </code></pre>
  
  <p>How can I avoid a crash if the next line is the end of the file? (i.e. null)</p>
  
  <p>I need to read the next line because there may be something there that I need to deal with but if there isn't the code just crashes.</p>
  
  <p>If there is something there then all is OK, but I can't be guaranteed that there will be something there.</p>
  
  <p>So if I do something like: (pseudo code):</p>
  
  <pre><code>if (r.readLine is null)
  //End code
  
  else {check line again and excecute code depending on what the next line is}
  </code></pre>
  
  <p>The issue I have with something like this is, that when I check the line against null, it already moves onto the next line, so how can I check it again?</p>
  
  <p>I've not worked out a way to do this - any suggestions would be a great help.</p>