DthingApi
Public Member Functions | List of all members
java.io.OutputStreamWriter Class Reference
Inheritance diagram for java.io.OutputStreamWriter:
java.io.Writer

Public Member Functions

 OutputStreamWriter (OutputStream out)
 
 OutputStreamWriter (OutputStream out, final String enc) throws UnsupportedEncodingException
 
void close () throws IOException
 
void flush () throws IOException
 
String getEncoding ()
 
void write (char[] buffer, int offset, int count) throws IOException
 
void write (int oneChar) throws IOException
 
void write (String str, int offset, int count) throws IOException
 
- Public Member Functions inherited from java.io.Writer
abstract void close () throws IOException
 
abstract void flush () throws IOException
 
void write (char[] buf) throws IOException
 
abstract void write (char[] buf, int offset, int count) throws IOException
 
void write (int oneChar) throws IOException
 
void write (String str) throws IOException
 
void write (String str, int offset, int count) throws IOException
 

Additional Inherited Members

- Protected Member Functions inherited from java.io.Writer
 Writer ()
 
 Writer (Object lock)
 
- Protected Attributes inherited from java.io.Writer
Object lock
 

Detailed Description

A class for turning a character stream into a byte stream. Data written to the target input stream is converted into bytes by either a default or a provided character converter. The default encoding is taken from the "file.encoding" system property.

contains a buffer of bytes to be written to target stream and converts these into characters as needed. The buffer size is 8K.

See also
InputStreamReader

Constructor & Destructor Documentation

◆ OutputStreamWriter() [1/2]

java.io.OutputStreamWriter.OutputStreamWriter ( OutputStream  out)
inline

Constructs a new OutputStreamWriter using

out

as the target stream to write converted characters to. The default character encoding is used.

Parameters
outthe non-null target stream to write converted bytes to.
Exceptions
UnsupportedEncodingException

◆ OutputStreamWriter() [2/2]

java.io.OutputStreamWriter.OutputStreamWriter ( OutputStream  out,
final String  enc 
) throws UnsupportedEncodingException
inline

Constructs a new OutputStreamWriter using

out

as the target stream to write converted characters to and

enc

as the character encoding. If the encoding cannot be found, an UnsupportedEncodingException error is thrown.

Parameters
outthe target stream to write converted bytes to.
encthe string describing the desired character encoding.
Exceptions
NullPointerExceptionif
enc
is
null
.
UnsupportedEncodingExceptionif the encoding specified by
enc
cannot be found.

Member Function Documentation

◆ close()

void java.io.OutputStreamWriter.close ( ) throws IOException
inline

Closes this writer. This implementation flushes the buffer as well as the target stream. The target stream is then closed and the resources for the buffer and converter are released.

Only the first invocation of this method has any effect. Subsequent calls do nothing.

Exceptions
IOExceptionif an error occurs while closing this writer.

◆ flush()

void java.io.OutputStreamWriter.flush ( ) throws IOException
inline

Flushes this writer. This implementation ensures that all buffered bytes are written to the target stream. After writing the bytes, the target stream is flushed as well.

Exceptions
IOExceptionif an error occurs while flushing this writer.

◆ getEncoding()

String java.io.OutputStreamWriter.getEncoding ( )
inline

Returns the historical name of the encoding used by this writer to convert characters to bytes, or null if this writer has been closed. Most callers should probably keep track of the String or Charset they passed in; this method may not return the same name.

◆ write() [1/3]

void java.io.OutputStreamWriter.write ( char []  buffer,
int  offset,
int  count 
) throws IOException
inline

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 gets full as a result of the conversion, this writer is flushed.

Parameters
bufferthe array containing characters to write.
offsetthe index of the first character in
buf
to write.
countthe maximum number of characters to write.
Exceptions
IndexOutOfBoundsExceptionif
offset < 0
or
count < 0
, or if
offset + count
is greater than the size of
buf
.
IOExceptionif this writer has already been closed or another I/O error occurs.

◆ write() [2/3]

void java.io.OutputStreamWriter.write ( int  oneChar) throws IOException
inline

Writes the character

oneChar

to this writer. The lowest two bytes of the integer

oneChar

are immediately converted to bytes by the character converter and stored in a local buffer. If the buffer gets full by converting this character, this writer is flushed.

Parameters
oneCharthe character to write.
Exceptions
IOExceptionif this writer is closed or another I/O error occurs.

◆ write() [3/3]

void java.io.OutputStreamWriter.write ( String  str,
int  offset,
int  count 
) throws IOException
inline

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 gets full as a result of the conversion, this writer is flushed.

Parameters
strthe string containing characters to write.
offsetthe start position in
str
for retrieving characters.
countthe maximum number of characters to write.
Exceptions
IOExceptionif this writer has already been closed or another I/O error occurs.
IndexOutOfBoundsExceptionif
offset < 0
or
count < 0
, or if
offset + count
is bigger than the length of
str
.

The documentation for this class was generated from the following file: