public final class CapturingWriter extends Writer
TeeWriter
and ProxyCollectionWriter
.Modifier and Type | Class and Description |
---|---|
static class |
CapturingWriter.Config
Configuration for
capturing writers . |
Constructor and Description |
---|
CapturingWriter(Writer output,
CapturingWriter.Config config)
Creates a new capturing writer.
|
Modifier and Type | Method and Description |
---|---|
Writer |
append(char c) |
Writer |
append(CharSequence csq) |
Writer |
append(CharSequence csq,
int start,
int end) |
String |
captured()
Returns the contents that have been captured.
|
void |
close() |
static CapturingWriter.Config.Builder |
config()
Creates a builder for capturing writer configurations.
|
void |
done()
Marks the capturing as done.
|
void |
flush() |
boolean |
isClosed()
Returns whether or not this writer has been closed.
|
long |
totalChars()
Returns the total number of characters that have been written.
|
void |
write(char[] c) |
void |
write(char[] c,
int off,
int len) |
void |
write(int c) |
void |
write(String str) |
void |
write(String str,
int off,
int len) |
public CapturingWriter(Writer output, CapturingWriter.Config config)
output
- The writer to capture from.config
- The configuration to use.NullPointerException
- If the given writer or config is null
.public void write(int c) throws IOException
write
in class Writer
IOException
public void write(char[] c) throws IOException
write
in class Writer
IOException
public void write(char[] c, int off, int len) throws IOException
write
in class Writer
IOException
public void write(String str) throws IOException
write
in class Writer
IOException
public void write(String str, int off, int len) throws IOException
write
in class Writer
IOException
public Writer append(CharSequence csq) throws IOException
append
in interface Appendable
append
in class Writer
IOException
public Writer append(CharSequence csq, int start, int end) throws IOException
append
in interface Appendable
append
in class Writer
IOException
public Writer append(char c) throws IOException
append
in interface Appendable
append
in class Writer
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class Writer
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
public void done()
done callback
still needs to be executed.public String captured()
public long totalChars()
public boolean isClosed()
true
if this writer has been closed, or false
otherwise.public static CapturingWriter.Config.Builder config()
Copyright © 2020–2024. All rights reserved.