public final class CapturingOutputStream extends OutputStream
TeeOutputStream
.Modifier and Type | Class and Description |
---|---|
static class |
CapturingOutputStream.Config
Configuration for
capturing output streams . |
Constructor and Description |
---|
CapturingOutputStream(OutputStream output,
CapturingOutputStream.Config config)
Creates a new capturing output stream.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
captured()
Returns the contents that have been captured.
|
String |
captured(Charset charset)
Returns the contents that have been captured, as a string.
|
void |
close() |
static CapturingOutputStream.Config.Builder |
config()
Creates a builder for capturing output stream configurations.
|
void |
done()
Marks the capturing as done.
|
void |
flush() |
boolean |
isClosed()
Returns whether or not this output stream has been closed.
|
long |
totalBytes()
Returns the total number of bytes that have been written.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public CapturingOutputStream(OutputStream output, CapturingOutputStream.Config config)
output
- The output stream to capture from.config
- The configuration to use.NullPointerException
- If the given output stream or config is null
.public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void done()
done callback
still needs to be executed.public byte[] captured()
public String captured(Charset charset)
charset
- The charset to use.public long totalBytes()
public boolean isClosed()
true
if this output stream has been closed, or false
otherwise.public static CapturingOutputStream.Config.Builder config()
Copyright © 2020–2024. All rights reserved.