java::io::OutputStreamWriter Class Reference

Inheritance diagram for java::io::OutputStreamWriter:

Inheritance graph
java::io::FileWriterjava::lang::Objectjava::lang::Interfacejava::io::Writer
[legend]
Collaboration diagram for java::io::OutputStreamWriter:

Collaboration graph
java::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::io::Writerjava::lang::Comparable
[legend]

List of all members.


Detailed Description

Write characters to an output stream, translating characters into bytes according to a specified character encoding.

Each OutputStreamWriter incorporates its own CharToByteConverter, and is thus a bridge from character streams to byte streams.

The encoding used by an OutputStreamWriter may be specified by name, by providing a CharToByteConverter, or by accepting the default encoding, which is defined by the system property file.encoding.

Each invocation of a write() method causes the encoding converter to be invoked on the given character(s). The resulting bytes are accumulated in a buffer before being written to the underlying output stream. The size of this buffer may be specified, but by default it is large enough for most purposes. Note that the characters passed to the write() methods are not buffered. For top efficiency, consider wrapping an OutputStreamWriter within a BufferedWriter so as to avoid frequent converter invocations. For example,

 Writer out
   = new BufferedWriter(new OutputStreamWriter(System.out));
 

Version:
1.10, 97/01/27
Author:
Mark Reinhold
Since:
JDK1.1

Public Member Functions

 OutputStreamWriter (const Ref< OutputStream > &out=0, const String &enc=nilCString)
 Create an OutputStreamWriter that uses the named character encoding.
const String getEncoding () const
 Return the name of the encoding being used by this stream.
virtual void write (jint c)
 Write a single character.
virtual void write (const Array< jchar > &b, jint ofs=0, jint len=-1)
 Write a portion of an array of characters.
virtual void write (const String &str, jint off=0, jint len=-1)
 Write a portion of a string.
virtual void flush ()
 Flush the stream.
virtual void close ()
 Close the stream.

Constructor & Destructor Documentation

java::io::OutputStreamWriter::OutputStreamWriter ( const Ref< OutputStream > &  out = 0,
const String enc = nilCString 
)

Create an OutputStreamWriter that uses the named character encoding.

Parameters:
out An OutputStream
enc Name of the encoding to be used
Exceptions:
UnsupportedEncodingException If the named encoding is not supported


Member Function Documentation

const String java::io::OutputStreamWriter::getEncoding (  )  const

Return the name of the encoding being used by this stream.

May return null if the stream has been closed.

virtual void java::io::OutputStreamWriter::write ( jint  c  )  [virtual]

Write a single character.

The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored.

Parameters:
c int specifying a character to be written.
Exceptions:
IOException If an I/O error occurs

Implements java::io::Writer.

virtual void java::io::OutputStreamWriter::write ( const Array< jchar > &  b,
jint  ofs = 0,
jint  len = -1 
) [virtual]

Write a portion of an array of characters.

Parameters:
cbuf Buffer of characters
off Offset from which to start writing characters
len Number of characters to write
Exceptions:
IOException If an I/O error occurs

Implements java::io::Writer.

virtual void java::io::OutputStreamWriter::write ( const String str,
jint  off = 0,
jint  len = -1 
) [virtual]

Write a portion of a string.

Parameters:
str A String
off Offset from which to start writing characters
len Number of characters to write
Exceptions:
IOException If an I/O error occurs

Implements java::io::Writer.

virtual void java::io::OutputStreamWriter::flush (  )  [virtual]

Flush the stream.

Exceptions:
IOException If an I/O error occurs

Reimplemented from java::io::Writer.

virtual void java::io::OutputStreamWriter::close (  )  [virtual]

Close the stream.

Exceptions:
IOException If an I/O error occurs

Reimplemented from java::io::Writer.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:32 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3