See ProcessBuilder in Java5 or System.runtime.exec() in earlier JDKs. These let you start another program as its own process. You can connect your own streams to the stdin, stdout and errout of the other process and read and write. This bit gets tricky as it works best with a separate thread for each stream. But once you get it all hung together you should be able to send it commands and read the responses.

See how far you get with this on your own. Post some code so we can see where you're stuck (if you get stuck) and we'll try to keep you moving along.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi

Elias Medeiros
Greenhorn

Joined: May 11, 2006
Posts: 4

posted May 16, 2006 14:54:00

0

I need write in the input "input" of process "p" and read from output "output" of process "p", right? But I only can read from an InputStream and I only can write in an outputStream. How can I solve this problem?

Originally posted by Elias Medeiros: I need write in the input "input" of process "p" and read from output "output" of process "p", right?

Wrong.

But I only can read from an InputStream and I only can write in an outputStream. How can I solve this problem?

By reading from the InputStream (which process "p" is writing to as stdout) and by writing to the OutputStream (which process "p" is reading from as stdin).

Elias Medeiros
Greenhorn

Joined: May 11, 2006
Posts: 4

posted May 18, 2006 14:27:00

0

ok, thanks.

Elias Medeiros
Greenhorn

Joined: May 11, 2006
Posts: 4

posted May 22, 2006 15:41:00

0

only more one question: I write in the output several times, but the input only can be read when the process "p" is finished (command "\n"). How can I do to allow the reading of input at each writing in the output?