DthingApi
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
java.io.Writer Class Referenceabstract
Inheritance diagram for java.io.Writer:
com.yarlungsoft.charset.StreamWriter java.io.OutputStreamWriter com.yarlungsoft.charset.ISO8859_1_Writer com.yarlungsoft.charset.UTF_8_Writer

Public Member Functions

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
 

Protected Member Functions

 Writer ()
 
 Writer (Object lock)
 

Protected Attributes

Object lock
 

Detailed Description

The base class for all writers. A writer is a means of writing data to a target in a character-wise manner. Most output streams expect the flush() method to be called before closing the stream, to ensure all data is actually written out.

This abstract class does not provide a fully working implementation, so it needs to be subclassed, and at least the write(char[], int, int), close() and flush() methods needs to be overridden. Overriding some of the non-abstract methods is also often advised, since it might result in higher efficiency.

Many specialized readers for purposes like reading from a file already exist in this package.

See also
Reader

Constructor & Destructor Documentation

◆ Writer() [1/2]

java.io.Writer.Writer ( )
inlineprotected

Constructs a new

with

this

as the object used to synchronize critical sections.

◆ Writer() [2/2]

java.io.Writer.Writer ( Object  lock)
inlineprotected

Constructs a new

with

used to synchronize critical sections.

Parameters
lockthe
Object
used to synchronize critical sections.
Exceptions
NullPointerExceptionif is
null
.

Member Function Documentation

◆ close()

abstract void java.io.Writer.close ( ) throws IOException
abstract

Closes this writer. Implementations of this method should free any resources associated with the writer.

Exceptions
IOExceptionif an error occurs while closing this writer.

◆ flush()

abstract void java.io.Writer.flush ( ) throws IOException
abstract

Flushes this writer. Implementations of this method should ensure that all buffered characters are written to the target.

Exceptions
IOExceptionif an error occurs while flushing this writer.

◆ write() [1/5]

void java.io.Writer.write ( char []  buf) throws IOException
inline

Writes the entire character buffer

buf

to the target.

Parameters
bufthe non-null array containing characters to write.
Exceptions
IOExceptionif this writer is closed or another I/O error occurs.

◆ write() [2/5]

abstract void java.io.Writer.write ( char []  buf,
int  offset,
int  count 
) throws IOException
abstract

Writes

count

characters starting at

offset

in

buf

to the target.

Parameters
bufthe non-null character array 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 is closed or another I/O error occurs.

◆ write() [3/5]

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

Writes one character to the target. Only the two least significant bytes of the integer

oneChar

are written.

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

◆ write() [4/5]

void java.io.Writer.write ( String  str) throws IOException
inline

Writes the characters from the specified string to the target.

Parameters
strthe non-null string containing the characters to write.
Exceptions
IOExceptionif this writer is closed or another I/O error occurs.

◆ write() [5/5]

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

Writes

count

characters from

str

starting at

offset

to the target.

Parameters
strthe non-null string containing the characters to write.
offsetthe index of the first character in
str
to write.
countthe number of characters from
str
to write.
Exceptions
IOExceptionif this writer is closed or another I/O error occurs.
IndexOutOfBoundsExceptionif
offset < 0
or
count < 0
, or if
offset + count
is greater than the length of
str
.

Member Data Documentation

◆ lock

Object java.io.Writer.lock
protected

The object used to synchronize access to the writer.


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