I am having this java code
public static main void (String[] args)
{
System.out.println("this is iteration 1");
System.out.println("this is iteration 2");
System.out.println("this is iteration 3");
System.out.println("this is iteration 4");
}
Python
import sys
try:
while True:
data = raw_input()
print "in python " + data
except:
print error
Desired output
In python : this is iteration 1
In python : this is iteration 2
In python : this is iteration 3
In python : this is iteration 4
Current output
In python : this is iteration 1
In python : this is iteration 2
In python : this is iteration 3
In python : this is iteration 4
Error
Basically what it does is that it was able to print out the four lines from stdout to stdin from java to python. However, when stdout has finished, i would like it to be blocking instead of running again.
My second question would be that, are the system.out.println all piped to the stdout buffer and the stdin reads them or they are read line by line?
My command to run the code is this
java -jar stdOut.jar | python testStdin.py