The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Standard Input / Output and Error of the 'executed' program

Posted by Salil V Gangal on July 08, 2001 at 12:13 PM

Friends,

On Windows platform I'm wondering about what happens to the Standard Input / Output and Error of a program that I'm executing from within my Java program by using the Runtime ?

Say there is some code such as ===>

public static void runAnExeFile ( String exeFileName )
{
Process p = null;
int status;
try {
Runtime r = Runtime.getRuntime();
p = r.exec(exeFileName);

}
catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}

try {
status = p.waitFor();
}
catch (InterruptedException e) {
status = -1;
}
if ( status == -1 ) {
System.err.println("Process is interrupted. Exiting ...");
System.exit(1);
}
}

So the question is what happens to the standard Input / Output and Error of the 'exeFileName' which is getting executed by the statements hilited in the above code ?

Regards,
Salil V Gangal



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us