InputStream coming from the external process, but you can use it with any InputStream.StreamGobbler is closedInputStream is read
StreamGobbler:null String. In that case the StreamGobbler.Listener.close() method will be called.
InputStream, which means that if the stream receives a lot of inputs in a short time, some of them could be discarded by the listener, leading to problems.Queue, which ensures that no event in the InputStream readings will be discarded:InputStream reading events and use them in the listener in another Thread. Between each even, there will be a delay of x ms, and a polling of y msInputStream reading events and use them in the listener in another Thread. Between each even, there will be a delay of x msInputStream reading events and use them in the listener in another Thread, with no delay
ProcessBuilder pb = new ProcessBuilder("my_executable.exe"); Process process = pb.start(); StreamGobbler outgobbler = new StreamGobbler(process.getInputStream()); List<String> lines = new ArrayList<> outgobbler.setListener(new StreamGobbler.Listener() { @Override public void readLine(String line) { lines.add(line); } @Override public void close() { } }); errorgobbler.start(); outgobbler.start();
Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences