Method Description

void close() Close this output stream and release any system resources associated with the stream. This method throws IOException when an I/O error occurs.

void flush() Flush this output stream by writing any buffered output bytes to the destination. If the intended destination of this output stream is an abstraction provided by the underlying platform (for example, a file), flushing the stream only guarantees that bytes previously written to the stream are passed to the underlying platform for writing; it does not guarantee that they are actually written to a physical device such as a disk drive. This method throws IOException when an I/O error occurs.

void write(byte[] b) Write b.length bytes from byte array b to this output stream. In general, write(b) behaves as if you specified write(b, 0, b.length). This method throws NullPointerException when b is null, and IOException when an I/O error occurs.

Method Description

Method Description void write(byte[] b, Write len bytes from byte array b starting at offset off to this output int off, int len) stream. This method throws NullPointerException when b is null;

java.lang.IndexOutOfBoundsException when off is negative, len is negative, or off+len is greater than b.length; and IOException when an I/O error occurs.

void write(int b) Write byte b to this output stream. Only the 8 low-order bits are written; the 24 high-order bits are ignored. This method throws IOException when an I/O error occurs.

The flush() method is useful in a long-running application where you need to save changes every so often; for example, the previously mentioned text-editor application that saves changes to a temporary file every few minutes.

NOTE: The close() method automatically flushes the output stream. If an application ends before close() is called, the output stream is automatically closed and its data is flushed.

InputStream is the superclass of all input stream subclasses. Table 10-8 describes InputStream's methods.

Table 10-8. InputStream Methods

Method

Was this article helpful?

0 0

Post a comment