An alternate to java. 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
| Modifier and Type | Class and Description |
|---|---|
| private static class | WriteThroughWriter.
An implementation of |
| private static class | WriteThroughWriter.
An implementation of |
| private static class | WriteThroughWriter.
An implementation of |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final ByteArrayOutputStream2 | |
| private final int | |
| pack-priv final OutputStream | |
| pack-priv static final int |
| Access | Constructor and Description |
|---|---|
| protected | |
| protected | WriteThroughWriter(OutputStream
The out, int OutputStream to write the converted bytes to.The maximum size in characters of a single conversion maxWriteSize)Construct an |
| Modifier and Type | Method and Description |
|---|---|
| public abstract WriteThroughWriter | append(CharSequence
The character sequence to append. If sequence)csq is
null, then the four characters "null" are
appended to this writer.Redeclares java. Overrides java. Appends the specified character sequence to this writer. |
| public void | close()
Implements abstract java. Implements java. Closes the stream, flushing it first. |
| public void | flush()
Implements abstract java. Implements java. Flushes the stream. |
| public int | |
| public static WriteThroughWriter | Returns: A Writer that willThe outputStream, String OutputStream to write to/The charset)Charset name.Obtain a new |
| public static WriteThroughWriter | Returns: A Writer that willThe outputStream, Charset OutputStream to write to/The charset)Charset.Obtain a new |
| pack-priv static CharSequence | Returns: A newCharSequence containing the subsequence, backed by the passed String
or the original String if it is the same.The string, int String to take a subsequence of.The offset in characters into the string to start the subsequence offset, int The length in characters of the substring length)Get a zero copy subsequence of a |
| pack-priv static CharSequence | Returns: A newCharSequence containing the subsequence.The characters to take a subsequence of. These character are not copied and the array should not be
modified for the life of the returned CharSequence. chars, int The offset in characters into the string to start the subsequence offset, int The length in characters of the substring length)Get a zero copy subsequence of a |
| public void | write(String
A String string, int Offset from which to start writing characters offset, int Number of characters to write length)Overrides java. Writes a portion of a string. |
| public void | write(char[]
Array of characters chars, int Offset from which to start writing characters offset, int Number of characters to write length)Implements abstract java. Writes a portion of an array of characters. |
| _bytes | back to summary |
|---|---|
| pack-priv final ByteArrayOutputStream2 _bytes | |
| _maxWriteSize | back to summary |
|---|---|
| private final int _maxWriteSize | |
| _out | back to summary |
|---|---|
| pack-priv final OutputStream _out | |
| DEFAULT_MAX_WRITE_SIZE | back to summary |
|---|---|
| pack-priv static final int DEFAULT_MAX_WRITE_SIZE | |
| WriteThroughWriter | back to summary |
|---|---|
| protected WriteThroughWriter(OutputStream out) | |
| WriteThroughWriter | back to summary |
|---|---|
| protected WriteThroughWriter(OutputStream out, int maxWriteSize) Construct an
| |
| append | back to summary |
|---|---|
| public abstract WriteThroughWriter append(CharSequence sequence) throws IOException Redeclares java. Overrides java. Doc from java. Appends the specified character sequence to this writer. An invocation of this method of the form out.write(csq.toString()) Depending on the specification of
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements abstract java. Implements java. Doc from java. Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements abstract java. Implements java. Doc from java. Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams. If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
| |
| getMaxWriteSize | back to summary |
|---|---|
| public int getMaxWriteSize() | |
| newWriter | back to summary |
|---|---|
| public static WriteThroughWriter newWriter(OutputStream outputStream, String charset) throws IOException Obtain a new
| |
| newWriter | back to summary |
|---|---|
| public static WriteThroughWriter newWriter(OutputStream outputStream, Charset charset) throws IOException Obtain a new
| |
| subSequence | back to summary |
|---|---|
| pack-priv static CharSequence subSequence(String string, int offset, int length) Get a zero copy subsequence of a Use of this is method can result in unforeseen GC consequences and can bypass
JVM optimizations available in
| |
| subSequence | back to summary |
|---|---|
| pack-priv static CharSequence subSequence(char[] chars, int offset, int length) Get a zero copy subsequence of a
| |
| write | back to summary |
|---|---|
| public void write(String string, int offset, int length) throws IOException Overrides java. Doc from java. Writes a portion of a string.
| |
| write | back to summary |
|---|---|
| public void write(char[] chars, int offset, int length) throws IOException Implements abstract java. Doc from java. Writes a portion of an array of characters.
| |
WriteThroughWriter that internally
uses java.io.OutputStreamWriter .
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Writer |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public WriteThroughWriter | append(CharSequence
The character sequence to append. If charSequence)csq is
null, then the four characters "null" are
appended to this writer.Implements abstract org. Implements java. Appends the specified character sequence to this writer. |
| _converter | back to summary |
|---|---|
| pack-priv final Writer _converter | |
| EncodingWriter | back to summary |
|---|---|
| public EncodingWriter(OutputStream out, String encoding) throws IOException | |
| EncodingWriter | back to summary |
|---|---|
| public EncodingWriter(OutputStream out, Charset charset) throws IOException | |
| append | back to summary |
|---|---|
| public WriteThroughWriter append(CharSequence charSequence) throws IOException Implements abstract org. Implements java. Doc from java. Appends the specified character sequence to this writer. An invocation of this method of the form out.write(csq.toString()) Depending on the specification of
| |
WriteThroughWriter for
optimal ISO-8859-1 conversion.
The ISO-8859-1 encoding is done by this class and no additional
buffers or Writers are used.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public WriteThroughWriter | append(CharSequence
The character sequence to append. If charSequence)csq is
null, then the four characters "null" are
appended to this writer.Implements abstract org. Implements java. Appends the specified character sequence to this writer. |
| Iso88591Writer | back to summary |
|---|---|
| private Iso88591Writer(OutputStream out) | |
| append | back to summary |
|---|---|
| public WriteThroughWriter append(CharSequence charSequence) throws IOException Implements abstract org. Implements java. Doc from java. Appends the specified character sequence to this writer. An invocation of this method of the form out.write(csq.toString()) Depending on the specification of
| |
WriteThroughWriter for
an optimal UTF-8 conversion.
The UTF-8 encoding is done by this class and no additional
buffers or Writers are used.
The UTF-8 code was inspired by ...
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public WriteThroughWriter | append(CharSequence
The character sequence to append. If charSequence)csq is
null, then the four characters "null" are
appended to this writer.Implements abstract org. Implements java. Appends the specified character sequence to this writer. |
| _surrogate | back to summary |
|---|---|
| pack-priv int _surrogate | |
| Utf8Writer | back to summary |
|---|---|
| private Utf8Writer(OutputStream out) | |
| append | back to summary |
|---|---|
| public WriteThroughWriter append(CharSequence charSequence) throws IOException Implements abstract org. Implements java. Doc from java. Appends the specified character sequence to this writer. An invocation of this method of the form out.write(csq.toString()) Depending on the specification of
| |