Java Reference
In-Depth Information
Equivalent to
write(buf,0, buf.length)
.
public void
write(String str, int offset, int count)
throws IOExcep-
tion
Writes
count
characters from the string
str
onto the stream,
starting with
str.charAt(offset)
.
public void
write(String str)
throws IOException
Equivalent to
write(str,0, str.length())
.
public abstract void
flush()
tHRows IOException
Flushes the stream. If the stream has buffered any characters
from the various
write
methods,
flush
immediately writes
them to their destination. Then, if that destination is another
stream, it is also flushed. One
flush
invocation will flush all
the buffers in a chain of streams. If a stream is not buffered
flush
will do nothing.
public abstract void
close()
throws IOException
Closes the stream, flushing if necessary. This method should
be invoked to release any resources (such as file descriptors)
associated with the stream. Once a stream has been closed,
further operations on the stream will throw an
IOException
.
Closing a previously closed stream has no effect.
Subclasses of
Writer
must implement the array writing variant of
write
,
the
close
method, and the
flush
method. All other
Writer
methods are
implemented in terms of these three. This contrasts with
OutputStream
which uses the single-byte variant of
write
method as the fundament-
al writing method, and which provides default implementations of
flush
and
close
. As with
Reader
, many subclasses can improve performance if
they also override other methods.