title: How to clear/reset/open an input stream so it can be used in 2 different methods in Java?
body: <p>Here's the code:</p>
  
  <pre><code>    package testpack;
      import java.io.*;
  
      public class InputStreamReadDemo {
  
  
          private void readByte() throws IOException {
              System.out.print("Enter the byte of data that you want to be read: ");        
              int a = System.in.read();
              System.out.println("The first byte of data that you inputted corresponds to the binary value "+Integer.toBinaryString(a)+" and to the integer value "+a+".");
              // tried writing System.in.close(); and System.in.reset();
          }
          private void readLine() throws IOException {
              BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
              System.out.print("Enter a line of text: ");
              String res = br.readLine();
              System.out.println("You entered the following line of text: "+res);
              // ... and tried writing br.close();
              // but that messes things up since the input stream gets closed and reset..
          }
  
          public static void main(String[] args) throws IOException {
              InputStreamReadDemo isrd = new InputStreamReadDemo();
              isrd.readByte();                                                // method 1
              isrd.readLine();                                                // method 2
          }
      }
  </code></pre>
  
  <p>Here's the output when I run this (and I input "Something" when the first method is called, the second method then auto-reads "omething" for some reason instead of letting me input again..):</p>
  
  <pre><code>run:
  Enter the byte of data that you want to be read: Something
  The first byte of data that you inputted corresponds to the binary value 1010011 and to the integer value 83.
  Enter a line of text: You entered the following line of text: omething
  BUILD SUCCESSFUL (total time: 9 seconds)
  </code></pre>