Package org.eclipse.jetty.io
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 Charset
s,
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
ModifierConstructorDescriptionprotected
protected
WriteThroughWriter
(OutputStream out, int maxWriteSize) Construct anOutputStreamWriter
-
Method Summary
Modifier and TypeMethodDescriptionabstract WriteThroughWriter
append
(CharSequence sequence) void
close()
void
flush()
int
static WriteThroughWriter
newWriter
(OutputStream outputStream, String charset) Obtain a newWriter
that converts characters written to bytes written to anOutputStream
.static WriteThroughWriter
newWriter
(OutputStream outputStream, Charset charset) Obtain a newWriter
that converts characters written to bytes written to anOutputStream
.void
write
(char[] chars, int offset, int length) void
-
Constructor Details
-
WriteThroughWriter
-
WriteThroughWriter
Construct anOutputStreamWriter
- Parameters:
out
- TheOutputStream
to 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 newWriter
that converts characters written to bytes written to anOutputStream
.- Parameters:
outputStream
- TheOutputStream
to write to/charset
- TheCharset
name.- 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 newWriter
that converts characters written to bytes written to anOutputStream
.- Parameters:
outputStream
- TheOutputStream
to 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Specified by:
write
in classWriter
- Throws:
IOException
-