keyboard into into a process object from within a thread

W

Wizumwalt

I have a JPanel where, when the user clicks a button, it starts a
MyProcess which is a class that I extend from Thread. From within the
run() of class MyProcess, I have code like the following ...

// ---
ProcessBuilder pb = new ProcessBuilder("aprogram.exe", myInputFile);

pb.directory(new File("aDir"));
pb.redirectErrorStream(true);

process = pb.start();

in = new BufferedReader(new
InputStreamReader(process.getInputStream()));
out = new BufferedWriter(new
OutputStreamWriter(process.getOutputStream()));
// ---

My problem is that, I want to type keyboard input from within my JPanel
and have it fed into the stream so that aProgram.exe receives it as
input. In sum, I want to feed a Process object keyboard input from a
program that drops the thread and get it into the other program
(aprogram.exe).

Can anyone help out on how that should/might work? Any help much
appreciated.
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top