Article View: borland.public.jbuilder.java.language
Article #19718Re: Problem using Process.waitFor() after exec()
From: cmm
Date: Tue, 06 Jan 1998 00:00
Date: Tue, 06 Jan 1998 00:00
38 lines
1765 bytes
1765 bytes
I understand that waitfor() does not would on Windows. Matthew Hyne wrote: > I have a peace of code that executes an application and places it's > STDOUT and STDERR into a Java Frame. > > The problem is, that after executing exec(application) I need to wait > for it to finish before I read the buffer but waitFor() never seems to > return. > > If I replay waitFor() with a delay the program works for most > applications - BUT WHY doesn't waitFor() work !!! > > I have placed an except of the code below > > Process process = Runtime.getRuntime().exec(command_string); > > // Capture output > BufferedReader proc_output = > new BufferedReader(new InputStreamReader( > new BufferedInputStream(process.getInputStream()))); > > BufferedReader proc_error = > new BufferedReader(new InputStreamReader( > new BufferedInputStream(process.getErrorStream()))); > > process.waitFor(); > > // For testing we use the below to simulate above > //Thread.currentThread().sleep(2000); > > while (proc_output.ready()) > textout.addLine(proc_output.readLine()+"\n"); > > while (proc_error.ready()) > textout.addLine(proc_error.readLine()+"\n");
Technical Details
Message-ID:
<34B2C471.A4D04DB6@dmwgroup.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3487A88C.736F96CD@tip.csiro.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,880cdb0fcebe042c X-Google-Attributes: gidf74b3,public From: cmm <cmavros@dmwgroup.com> Subject: Re: Problem using Process.waitFor() after exec() Date: 1998/01/06 Message-ID: <34B2C471.A4D04DB6@dmwgroup.com> X-Deja-AN: 313449017 Content-Transfer-Encoding: 7bit References: <3487A88C.736F96CD@tip.csiro.au> To: Matthew Hyne <mhyne@tip.csiro.au> Content-Type: text/plain; charset=us-ascii Organization: None Mime-Version: 1.0 Reply-To: cmavros@dmwgroup.com Newsgroups: borland.public.jbuilder.java.language