Package jetbrains.buildServer
Class LineAwareByteArrayOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.ByteArrayOutputStream
-
- jetbrains.buildServer.LineAwareByteArrayOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class LineAwareByteArrayOutputStream extends java.io.ByteArrayOutputStream
A ByteArrayOutputStream which decodes bytes into string and invokes the given callback when a new line is detected. Can be used as outputStream inStreamGobbler
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LineAwareByteArrayOutputStream.LineListener
-
Constructor Summary
Constructors Constructor Description LineAwareByteArrayOutputStream(java.nio.charset.Charset charset, LineAwareByteArrayOutputStream.LineListener listener)
LineAwareByteArrayOutputStream(java.nio.charset.Charset charset, LineAwareByteArrayOutputStream.LineListener listener, boolean accumulateBytes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
setCREndsLine(boolean CREndsLine)
void
write(byte[] b, int off, int len)
-
-
-
Constructor Detail
-
LineAwareByteArrayOutputStream
public LineAwareByteArrayOutputStream(@NotNull java.nio.charset.Charset charset, @NotNull LineAwareByteArrayOutputStream.LineListener listener)
-
LineAwareByteArrayOutputStream
public LineAwareByteArrayOutputStream(@NotNull java.nio.charset.Charset charset, @NotNull LineAwareByteArrayOutputStream.LineListener listener, boolean accumulateBytes)
-
-
Method Detail
-
setCREndsLine
public void setCREndsLine(boolean CREndsLine)
-
write
public void write(byte[] b, int off, int len)
- Overrides:
write
in classjava.io.ByteArrayOutputStream
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.ByteArrayOutputStream
- Throws:
java.io.IOException
-
-