The Process
returned from the exec
call contains three streams:
process.getOutputStream()
which, if you write to, will be 'piped' in to the running process
process.getInputStream()
which, if read from, will contain the standard output (the ls
output)
process.getErrorStream()
whihc, if read from, will contain the standard error output (error messages from running ls
, if any).
It is your responsibility as the programmer, to read from these streams, and to output them to your program's output, if that's what you want.
Also, you should check the process.exitValue()
if you want to get that too.
it is somewhat common to set up separate threads to monitor the Stdout and Stderr streams