?
=?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
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