However, when i run the os.write method, the String just prints to the console. i thought my code was sufficient to reassign it and prevent it from being output there. what am i missing here?
PrintStream os = System.out; System.setOut(os); InputStream is = System.in; System.setIn(is); os.write("I HOPE THIS WORKS!!!!!!!!!".getBytes()); int available = is.available(); byte BYTE = new byte; //just trying to read the first 6 bytes, for the heck of it! is.read(BYTE);
but it SEEMS like i should be able to write to STDOUT, then have it wait for me until i read from STDIN.
I tried the following code:You however are missing the point that a stream has two ends. The streams you are grabbing do not let you control both ends (within java.)