Alex Rivera | Logout

Capturing stdout when calling Runtime.exec

Asked 2009-05-19T13:31:34.400
59

When experiencing networking problems on client machines, I'd like to be able to run a few command lines and email the results of them to myself.

I've found Runtime.exec will allow me to execute arbitrary commands, but Collecting the results in a String is more interesting.

I realize I could redirect output to a file, and then read from the file, but my spidey sense is telling me there's a more elegant way of doing it.

Suggestions?

Edit
Report

1 Answer

0

Runtime.exec() returns a Process object, from which you can extract the output of whatever command you ran.

answered 2009-05-19T13:33:56.983

Your Answer