title: Change System.in and make Scanners use one ByteArrayInputStream?
body: <p>I am tasked with writing a test program to assess whether a student's homework works or not. 
  The students are writing a Rock, Paper, Scissors game in Java and turning in single class that plays through a game with n rounds by asking the user for input in the command line.
  All of these students will be using one or more Scanner objects to read input off of the console, so I need to make my test program simulate some predetermined inputs and check for expected outputs. 
  I override System.in, so when a student calls <code>Scanner myReader = new Scanner(System.in);</code>, I get to dictate what the input is (using ByteArrayInputStream).
  To get an idea of how I've started:</p>
  
  <pre><code>public class TestRockPaperScissors extends RockPaperScissors{
  public static void main(String[] args){
      InputStream stdin = System.in;
      try {
      System.setIn(new ByteArrayInputStream("&lt;test inputs here&gt;".getBytes()));
      RockPaperScissors.main(null); // This will be student code in another file.
      } finally {
          System.setIn(stdin);
      }
  
  }
  </code></pre>
  
  <p>Problem is, this only works when the student only creates a single Scanner using System.in. Otherwise, I get errors, because there is no input present for the second Scanner to use .next() on. </p>
  
  <p>TL;DR... How do I simulate console input for an arbitrary number of Scanners, given that I cannot see the source of the RockPaperScissors.main(null) call?</p>