Class WriterStream
java.lang.Object
java.io.OutputStream
com.sun.javatest.util.WriterStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Note: this class should be JDK 1.1 compatible
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a stream that writes to a writer.WriterStream(Writer w, String charsetName) Create a stream that writes to a writer. -
Method Summary
Methods inherited from class OutputStream
nullOutputStream, write, write
-
Constructor Details
-
WriterStream
-
WriterStream
-
-
Method Details
-
flush
Flush the stream.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException- if an I/O error occurs
-
close
We override default implementation to write last characters, which could be lost in buffer otherwise.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
write
OutputStream's implementation. Our goal is to convert encoded byte stream form OutputStream to char stream, which can be written using specified writer. We perform this by collecting bytes in buffer and checking with PERIOD_SIZE interval if this buffer represents some char sequence. If so, we write to writer all chars, except last one. We don't write last char, because there still not enough bytes could be collected for it.- Specified by:
writein classOutputStream- Parameters:
b- next byte from OutputStream to write.- Throws:
IOException
-