How do I pipe input into a java program, but have that input still show in the output?
<p>Let's say I have a program that asks for three numbers using scanner, something like this:</p>

<pre><code>Scanner console = new Scanner(System.in);
int[] numbers = new int[3];
System.out.println("Hello!");
for (int i = 0; i&lt;3; i++){
    System.out.print("Please enter a number: ");
    numbers[i] = console.nextInt();
}
</code></pre>

<p>I want to test a program like this by redirecting some input to it, and then redirecting the output to a file.</p>

<p>input.txt</p>

<pre><code>3
4
5
</code></pre>

<p>command</p>

<pre><code>java program &lt; input.txt &gt; output.txt
</code></pre>

<p>The problem is that the output.txt will look something like this</p>

<pre><code>Hello!
Please enter a number: Please enter a number: Please enter a number: 
</code></pre>

<p>As opposed to something like this</p>

<pre><code>Hello!
Please enter a number: 3
Please enter a number: 4
Please enter a number: 5
</code></pre>

<p>Is there any way to make output.txt look more like the second one? I'm on a Mac, if that changes anything. </p>

<p><strong>I do NOT want to modify the code</strong> - I have to run this test for a lot of similar programs. </p>