I am confused regarding use of input stream and output stream. From a stack overflow question confused about stdin, stdout and stderr? :
Standard input - this is the file handle that your process reads to get information from you.
Standard output - your process writes normal information to this file handle.
I was trying to run an external process(A python script) using java.Which is an interactive one and requires input from user.
Now as concept says that:
standard input is used when your process reads to get information from you.
So I should get input stream from the process to write values to it.I tried to it and failed .So I searched on stack overflow gave me a question with same problem which was taking output stream from process and then was writing to it.I tried that and that worked.
My question is that why that worked? Shouldn't it be input stream which I should use to give input to that external process or I have understood input stream and output stream totally wrong.
Please help me to understand it with an easy explanation .
Edit : My code was :
Process process=Runtime.getRuntime().exec("/usr/bin/python /home/abhijeet/test.py");
OutputStream stdin = process.getOutputStream ();
String line = "30" + "\n";
stdin.write(line.getBytes() );