Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Input / output to an external process

Reply
Thread Tools

Input / output to an external process

 
 
=?ISO-8859-1?Q?Reidar_=D8ksnevad?=
Guest
Posts: n/a
 
      07-28-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Buffered output from external process? reid Java 4 04-09-2009 02:42 PM
Simple HTML User Input and Process Output W. D. Allen Sr. HTML 2 09-12-2005 09:26 PM
External process output missing Guifre Java 1 05-24-2005 12:12 PM
(Win32) Timing out a process while reading process' output? rtm Perl 0 09-27-2004 10:06 PM
Python reading output from a running, external process Brian Elmegaard Python 2 09-10-2003 09:47 PM



Advertisments