Name
OutputStreamWriter
Synopsis
This class is a character output stream
that uses a byte output stream as the destination for its data. When
characters are written to an
OutputStreamWriter, it translates
them into bytes according to a particular
locale- and/or platform-specific
character encoding and writes those bytes to the specified
OutputStream. This is a very important
internationalization feature in Java 1.1 and later.
OutputStreamWriter supports the usual
Writer methods. It also has a
getEncoding( )
method that returns the name of the
encoding being used to convert characters to bytes.
When you create an OutputStreamWriter, specify the
OutputStream to which it writes bytes and,
optionally, the name of the character encoding that should be used to
convert characters to bytes. If you do not specify an encoding name,
the OutputStreamWriter uses the default encoding
of the default locale, which is usually the correct thing to do. In
Java 1.4 and later, this class uses the
charset
conversion facilities of the java.nio.charset
package and allows you to explicitly specify the
Charset or CharsetEncoder to be
used. Prior to Java 1.4, the class allows you to specify only the
name of the desired charset encoding.
Figure 9-44. java.io.OutputStreamWriter
public class OutputStreamWriter extends Writer { // Public Constructors public OutputStreamWriter(OutputStream out); public OutputStreamWriter ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access