public class OutputStreamStringCollector extends java.lang.Object implements java.lang.AutoCloseable, StringCollector
Usually should be closed after usage. Recommend is to use it in try-with-resources-
| Modifier and Type | Field and Description |
|---|---|
static java.nio.charset.Charset |
DEFAULT_CHARSET
The default charset (UTF_8).
|
| Constructor and Description |
|---|
OutputStreamStringCollector(java.io.OutputStream stream)
Constructor.
|
OutputStreamStringCollector(java.io.OutputStream stream,
java.nio.charset.Charset charset)
Constructor.
|
OutputStreamStringCollector(java.io.OutputStream stream,
java.lang.String charsetName)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(char ch)
Add a character to this collector.
|
void |
add(java.lang.String str)
Add a string t this collector.
|
void |
close()
Closes this stream and releases any system resources associated
with it.
|
java.io.IOException |
getError()
Get a possible error.
|
char |
getLastLetter()
Get the last letter of the last string which was added.
|
void |
rethrow()
Rethrow an error which was caught during writing of added strings.
|
public static final java.nio.charset.Charset DEFAULT_CHARSET
public OutputStreamStringCollector(@NotNull java.io.OutputStream stream)
DEFAULT_CHARSET for output encoding.stream - output streampublic OutputStreamStringCollector(@NotNull java.io.OutputStream stream, @NotNull java.lang.String charsetName)
stream - output streamcharsetName - name of charset to use for output encodingpublic void add(@NotNull java.lang.String str)
add in interface StringCollectorstr - string collectorpublic void add(char ch)
add in interface StringCollectorch - character to addpublic char getLastLetter()
getLastLetter in interface StringCollectorpublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseablejava.io.IOException - if an I/O error occurspublic void rethrow()
throws java.io.IOException
java.io.IOException - exception caught during writing strings@Nullable public java.io.IOException getError()