title: How should I read from a buffered reader?
body: <p>I have the following example of reading from a buffered reader:</p>
  
  <pre><code>while ((inputLine = input.readLine()) != null) {
     System.out.println("I got a message from a client: " + inputLine);
  }
  </code></pre>
  
  <p>The code in the loop <code>println</code> will be executed whenever something appears in the buffered reader (<code>input</code> in this case). In my case, if a client-application writes something to the socket, the code in the loop (in the server-application) will be executed.</p>
  
  <p>But I do not understand how it works. <code>inputLine = input.readLine()</code> waits until something appears in the buffered reader and when something appears there it returns <code>true</code> and the code in the loop is executed. But when <code>null</code> can be returned.</p>
  
  <p>There is another question. The above code was taken from a method which <code>throws Exception</code> and I use this code in the run method of the Thread. And when I try to put <code>throws Exception</code> before the <code>run</code> the compiler complains: overridden method does not throw exception. Without the <code>throws exception</code> I have another complain from the compiler: unreported exception. So, what can I do?</p>