Is there a way to write to an outputstream that will be read by the System.in input stream? For example:
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.in));
Except that doesn’t work because System.in is an input stream and OutputStreamWriter takes an outputstream.
I want to output something that will be read by:
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
What I am trying to do is write a unit test for a console application. I want to programatically test my input. Any way to do this would answer my question.
My suggestion is that you make methods with method(String/int var) and have a separate parser. Then you can test all methods without having to have an input. This is standard in unit-testing.