Ok, here's what I have:
PHP Code:
try {proc = Runtime.getRuntime().exec("cat");} catch (IOException e) {}
in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
out = new PrintWriter(new OutputStreamWriter(proc.getOutputStream()));
try {
out.write("hello");
System.out.println(">> ");
String s = in.readLine();
System.out.println(">> " + s);
} catch (Exception e) {e.printStackTrace();}
The output of above is ">>".
In other works, it just hangs (doesn't crash) at in.readLine()
I tried separating the reading and writing in separate threads but to the same effect.
P.S. ooookay, wait a sec, I just flushed the output stream and it seems to work... I'll do some more testing.
P.S. Yep, it works
Basically, the solution was to use println instead of write (or add "\n" to the string), and flush the stream right away.
Makes me feel so smart hehe.
Bookmarks