I have started a process in my Java code, this process takes a long time to run and from time to time Can produce some output on time When I am born I need to react to every output, what is the best way to do this?
What kind of feedback are you talking about? Is the process writing its standard output and / or standard error? If so, I suspect that Process.getInputStream and Process.getErrorStream are those you are looking for. Read them both and respond accordingly. Note that you may want to read both of them separately, so that any buffer can be avoided by filling any stream.
Alternatively, if you do not need two separate, then just type in the redirect rule in the form of ProcessBuilder , error and Output streams are merged.
Comments
Post a Comment