java new process – is necessary to get and read from ErrorStreams and Output streams – Education Career Blog

I create new process from a java code using ProcessBuilder

ProcessBuilder builder = new ProcessBuilder("/path/to/bin");
Process process = builder.start();

In this case, I am not interested in seeing error/output. Is it necessary to grab OutputStream and ErrorStream? Is it automatically ignored?

Output may be large (10MB) — in some cases.


You’re not required to do anything with those streams, but you should be aware that the created process may block if the output buffers become full. If you know that the process you are creating does not produce much (or any) output to stdout or stderr then you’re probably OK, otherwise you should create threads that read and discard the output from each stream.

Leave a Comment