Input / output to an external process

  • Thread starter =?ISO-8859-1?Q?Reidar_=D8ksnevad?=
  • Start date
?

=?ISO-8859-1?Q?Reidar_=D8ksnevad?=

Hi,

I have a program that uses the ProcessBuilder class to invoke an external
program (kpsewhich). This works fine when I only want to pass an argument
to the program, and return one line of output:

<code>
kpseProcess = new ProcessBuilder("kpsewhich", filename).start();
kpseReader = new BufferedReader(new InputStreamReader(
kpseProcess.getInputStream()));
kpseProcess.waitFor(); // wait for process to end

String output = kpseReader.readLine();
</code>

The problem with this solution is that kpsewhich has an "interactive"
mode, which allows the caller to keep the process running, and simply pass
file names through its input stream.

I would therefore like to have the process running in a separate thread,
and send input whenever I need to. I have been trying to do this using the
process' output stream, kpseProcess.getOutputStream(), but with no luck.

Can anyone point me in the right direction?

Regards,
Reidar Øksnevad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top