| java.lang.Object java.io.Writer java.io.OutputStreamWriter
All known Subclasses: java.io.FileWriter,
OutputStreamWriter | public class OutputStreamWriter extends Writer (Code) | | OutputStreamWriter is a class for turning a character output stream into a
byte output stream. The conversion of Unicode characters to their byte
equivalents is determined by the converter used. By default, the encoding is
ISO8859_1 (ISO-Latin-1) but can be changed by calling the constructor which
takes an encoding.
See Also: InputStreamReader |
Constructor Summary | |
public | OutputStreamWriter(OutputStream out) Constructs a new OutputStreamWriter using out as the
OutputStream to write converted characters to. | public | OutputStreamWriter(OutputStream out, String enc) Constructs a new OutputStreamWriter using out as the
OutputStream to write converted characters to and enc as
the character encoding. | public | OutputStreamWriter(OutputStream out, Charset cs) Constructs a new OutputStreamWriter using out as the
OutputStream to write converted characters to and cs as
the character encoding. | public | OutputStreamWriter(OutputStream out, CharsetEncoder enc) Constructs a new OutputStreamWriter using out as the
OutputStream to write converted characters to and enc as
the character encoding. |
Method Summary | |
public void | close() Close this OutputStreamWriter. | public void | flush() Flush this OutputStreamWriter. | public String | getEncoding() Answer the String which identifies the encoding used to convert
characters to bytes. | public void | write(char[] buf, int offset, int count) Writes count characters starting at offset
in buf to this Writer. | public void | write(int oneChar) Writes out the character oneChar to this Writer. | public void | write(String str, int offset, int count) Writes count characters starting at offset
in str to this Writer. |
OutputStreamWriter | public OutputStreamWriter(OutputStream out)(Code) | | Constructs a new OutputStreamWriter using out as the
OutputStream to write converted characters to. The default character
encoding is used (see class description).
Parameters: out - the non-null OutputStream to write converted bytes to. |
OutputStreamWriter | public OutputStreamWriter(OutputStream out, String enc) throws UnsupportedEncodingException(Code) | | Constructs a new OutputStreamWriter using out as the
OutputStream to write converted characters to and enc as
the character encoding. If the encoding cannot be found, an
UnsupportedEncodingException error is thrown.
Parameters: out - the non-null OutputStream to write converted bytes to. Parameters: enc - the non-null String describing the desired character encoding. throws: UnsupportedEncodingException - if the encoding cannot be found. |
OutputStreamWriter | public OutputStreamWriter(OutputStream out, Charset cs)(Code) | | Constructs a new OutputStreamWriter using out as the
OutputStream to write converted characters to and cs as
the character encoding.
Parameters: out - the non-null OutputStream to write converted bytes to. Parameters: cs - the non-null Charset which specify the character encoding. |
OutputStreamWriter | public OutputStreamWriter(OutputStream out, CharsetEncoder enc)(Code) | | Constructs a new OutputStreamWriter using out as the
OutputStream to write converted characters to and enc as
the character encoding.
Parameters: out - the non-null OutputStream to write converted bytes to. Parameters: enc - the non-null CharsetEncoder which used to character encoding. |
close | public void close() throws IOException(Code) | | Close this OutputStreamWriter. This implementation first flushes the
buffer and the target OutputStream. The OutputStream is then closed and
the resources for the buffer and converter are freed.
Only the first invocation of this method has any effect. Subsequent calls
do no work.
throws: IOException - If an error occurs attempting to close thisOutputStreamWriter. |
flush | public void flush() throws IOException(Code) | | Flush this OutputStreamWriter. This implementation ensures all buffered
bytes are written to the target OutputStream. After writing the bytes,
the target OutputStream is then flushed.
throws: IOException - If an error occurs attempting to flush thisOutputStreamWriter. |
getEncoding | public String getEncoding()(Code) | | Answer the String which identifies the encoding used to convert
characters to bytes. The value null is returned if this
Writer has been closed.
the String describing the converter or null if this Writer isclosed. |
write | public void write(char[] buf, int offset, int count) throws IOException(Code) | | Writes count characters starting at offset
in buf to this Writer. The characters are immediately
converted to bytes by the character converter and stored in a local
buffer. If the buffer becomes full as a result of this write, this Writer
is flushed.
Parameters: buf - the non-null array containing characters to write. Parameters: offset - offset in buf to retrieve characters Parameters: count - maximum number of characters to write throws: IOException - If this OutputStreamWriter has already been closed or someother IOException occurs. throws: IndexOutOfBoundsException - If offset or count is outside of bounds. |
write | public void write(int oneChar) throws IOException(Code) | | Writes out the character oneChar to this Writer. The
low-order 2 bytes are immediately converted to bytes by the character
converter and stored in a local buffer. If the buffer becomes full as a
result of this write, this Writer is flushed.
Parameters: oneChar - the character to write throws: IOException - If this OutputStreamWriter has already been closed or someother IOException occurs. |
write | public void write(String str, int offset, int count) throws IOException(Code) | | Writes count characters starting at offset
in str to this Writer. The characters are immediately
converted to bytes by the character converter and stored in a local
buffer. If the buffer becomes full as a result of this write, this Writer
is flushed.
Parameters: str - the non-null String containing characters to write. Parameters: offset - offset in str to retrieve characters Parameters: count - maximum number of characters to write throws: IOException - If this OutputStreamWriter has already been closed or someother IOException occurs. throws: IndexOutOfBoundsException - If count is negative throws: StringIndexOutOfBoundsException - If offset is negative or offset + count is outside of bounds |
|
|