Hi all, I need a hand with a problem that I'm running into. I haven't messed with threads for a few years, so I'm a bit rusty... I have an application that needs to run a console app, grab the output and error streams, feed interactive info to the app, read the output and then close the app. For some reason, the app never exits and the threads don't complete. I have tried: creating a process getting error stream and output stream from that process and put each into a thread start the threads writing to the process output doing a waitFor on the process threads don't complete - they seem to hang up on: while ((s = bufferedreader.readLine()) != null) Any ideas? Thanks, Paul
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18652
posted
0
Well, readLine() is looking for a line terminator. Perhaps one of the streams has printed a partial line, with no line terminator? Try replacing readLine() with read(char[]), and print whatever is read.
"I'm not back." - Bill Harding, Twister
Paul Smiley
Ranch Hand
Joined: Jun 02, 2000
Posts: 244
posted
0
Thanks, Jim, but that doesn't seem to be doing it. It seems as if my interactive commands don't seem to be working. Maybe I'll try to put them in a batch file and run them that way and see if I can get a result. Hey, long time no talk to!!!
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18652
posted
0
Yeah, it's been a while since we saw you here. Good to see you're still around. If you're feeding the app info through the Process's OutputStream, perhaps you need to close the stream so it knows there's no more input? Putting everything in a batch file (if possible) sounds like a good approach. At least it's easier to debug initially just by running the batch file outside Java. Once that's done (and you're verified that the batch file completes without hanging), it should be relatively simple to call from Java. Um, hopefully.