If I start a process via Java\'s ProcessBuilder class, I have full access to that process\'s standard in, standard out, and standard error streams as Java InputStreams
For System.in
use the following pipein()
instead of pipe()
pipein(System.in, p.getOutputStream());
Implementation:
private static void pipein(final InputStream src, final OutputStream dest) {
new Thread(new Runnable() {
public void run() {
try {
int ret = -1;
while ((ret = System.in.read()) != -1) {
dest.write(ret);
dest.flush();
}
} catch (IOException e) { // just exit
}
}
}).start();
}