Class LineAwareByteArrayOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public class LineAwareByteArrayOutputStream
    extends ByteArrayOutputStream
    A ByteArrayOutputStream which decodes bytes into string and invokes the given callback when a new line is detected. Can be used as outputStream in StreamGobbler to get progress from external process without waiting for process to finish. By default it accumulates written bytes (as does normal ByteArrayOutputStream), this can be disabled, so that written bytes are not accumulated, but callback is notified about detected lines. This is useful if external process reports only progress and its output can be big.