title: Closing Reader/Stream in Java
body: <p>In my code I have to read user input from console:</p>
  
  <pre><code>class Demo {
      //...some code
      public String readUserInput() throws IOException {
          BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
          String userInput = reader.readLine();
          reader.close();
          return userInput;
      }
  }
  </code></pre>
  
  <p>On first time when I use method <code>readUserInput()</code> on Demo object everything is OK. But when I create another Demo object and call method - it throws Exception with the message </p>
  
  <blockquote>
    <p>"Stream closed"</p>
  </blockquote>
  
  <p>Can anybody tell me, why I have Exception on different not equal objects? Thank you for your attention.</p>