java.lang.Object
java.io.Writer
io.github.ascopes.jct.diagnostics.TeeWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
A writer that wraps an output stream and also writes any content to an in-memory buffer.
This is thread-safe.
- Since:
- 0.0.1
- Author:
- Ashley Scopes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()Get the content of the internal buffer.toString()Get the content of the internal buffer.static TeeWriterwrapOutputStream(OutputStream outputStream, Charset charset) Create a tee writer for the given output stream.voidwrite(char[] buffer, int offset, int length)
-
Constructor Details
-
TeeWriter
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
getContent
Get the content of the internal buffer.- Returns:
- the content.
- Since:
- 0.2.1
-
toString
Get the content of the internal buffer.This calls
getContent()internally as of 0.2.1. -
write
- Specified by:
writein classWriter- Throws:
IOException
-
wrapOutputStream
@API(since="0.2.1", status=STABLE) public static TeeWriter wrapOutputStream(OutputStream outputStream, Charset charset) Create a tee writer for the given output stream.Remember you may need to manually flush the tee writer for all contents to be committed to the output stream.
- Parameters:
outputStream- the output stream.charset- the charset.- Returns:
- the Tee Writer.
- Since:
- 0.2.1
-