Java Reference
In-Depth Information
public void write(byte[] buf) throws IOException
Equivalent to write(buf,0, buf.length) .
public void flush() throws IOException
Flushes the stream. If the stream has buffered any bytes from
the various write methods, flush writes them immediately 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 the stream is not buffered, flush may
do nothingthe default implementation. This method is defined
in the Flushable interface.
public void close() tHRows IOException
Closes the output stream. This method should be invoked to
release any resources (such as file descriptors) associated
with the stream. Once a stream has been closed, further oper-
ations on the stream will throw an IOException . Closing a pre-
viously closed stream has no effect.The default implementa-
tion of close does nothing.
The implementation of OutputStream requires only that a subclass provide
the single-byte variant of write because the other write methods are
defined in terms of this one. Most streams, however, can improve per-
formance by overriding other methods as well. The default implementa-
tions of flush and close will usually need to be overridden as appropriate
for a particular streamin particular, buffered streams may need to flush
when closed.
Here is a program that copies its input to its output, translating one par-
ticular byte value to a different one along the way. The TRanslateByte
program takes two parameters: a from byte and a to byte. Bytes that
match the value in the string from are translated into the value in the
string to .
 
Search WWH ::




Custom Search