Class WriteThroughWriter
java.lang.Object
java.io.Writer
org.eclipse.jetty.io.WriteThroughWriter
- All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
An alternate to OutputStreamWriter that supports
several optimized implementation for well known Charsets,
specifically StandardCharsets.UTF_8 and StandardCharsets.ISO_8859_1.
The implementations of this class will never buffer characters or bytes beyond a call to the
write(char[], int, int) method, thus written characters will always be passed
as bytes to the passed OutputStream
-
Field Summary
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedWriteThroughWriter(OutputStream out, int maxWriteSize) Construct anOutputStreamWriter -
Method Summary
Modifier and TypeMethodDescriptionabstract WriteThroughWriterappend(CharSequence sequence) voidclose()voidflush()intstatic WriteThroughWriternewWriter(OutputStream outputStream, String charset) Obtain a newWriterthat converts characters written to bytes written to anOutputStream.static WriteThroughWriternewWriter(OutputStream outputStream, Charset charset) Obtain a newWriterthat converts characters written to bytes written to anOutputStream.voidwrite(char[] chars, int offset, int length) void
-
Constructor Details
-
WriteThroughWriter
-
WriteThroughWriter
Construct anOutputStreamWriter- Parameters:
out- TheOutputStreamto write the converted bytes to.maxWriteSize- The maximum size in characters of a single conversion
-
-
Method Details
-
newWriter
public static WriteThroughWriter newWriter(OutputStream outputStream, String charset) throws IOException Obtain a newWriterthat converts characters written to bytes written to anOutputStream.- Parameters:
outputStream- TheOutputStreamto write to/charset- TheCharsetname.- Returns:
- A Writer that will
- Throws:
IOException- If there is a problem creating theWriter.
-
newWriter
public static WriteThroughWriter newWriter(OutputStream outputStream, Charset charset) throws IOException Obtain a newWriterthat converts characters written to bytes written to anOutputStream.- Parameters:
outputStream- TheOutputStreamto write to/charset- TheCharset.- Returns:
- A Writer that will
- Throws:
IOException- If there is a problem creating theWriter.
-
getMaxWriteSize
public int getMaxWriteSize() -
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
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Specified by:
writein classWriter- Throws:
IOException
-