java.io.OutputStream
java.lang.Object
java.io.ByteArrayOutputStream,
java.io.FileOutputStream,
java.io.FilterOutputStream,
java.io.ObjectOutputStream,
java.io.PipedOutputStream
None
JDK 1.0 or later
The OutputStream class is an abstract class that is the superclass of all classes that represent output byte streams. OutputStream defines the basic output methods that all output streams provide. A similar hierarchy of classes, based around Writer, deals with character streams instead of byte streams.
OutputStream is designed so that write(byte[]) and write(byte[], int, int) call write(int b). Thus, a subclass can simply override write(), and all the write methods will work. However, for efficiency's sake, write(byte[], int, int) should also be overridden with a method that can write a block of data more efficiently than writing each byte separately.
Some OutputStream subclasses may implement buffering to increase efficiency. OutputStream provides a method, flush(), that tells the OutputStream to write any buffered output to the underlying device, which may be a disk drive or a network.
public abstract class java.io.OutputStream extends java.lang.Object { // Instance Methods public void close(); public void flush(); public abstract void write(int b); public void write(byte[] b); public void write(byte[] b, int off, int len); }
If any kind of I/O error occurs.
This method closes the output stream and releases any resources associated with it.
The implementation of the close() method in OutputStream does nothing; a subclass should override this method to handle cleanup for the stream.
If any kind of I/O error occurs.
This method forces any bytes that may be buffered by the output stream to be written.
The implementation of flush() in OutputStream does nothing; a subclass should override this method as needed.
The value to write to the stream.
If any kind of I/O error occurs.
This method writes a byte of output. The method blocks until the byte is actually written.
A subclass of OutputStream must implement this method.
An array of bytes to write to the stream.
If any kind of I/O error occurs.
This method writes the bytes from the given array by calling write(b, 0, b.length). The method blocks until the bytes are actually written.
A subclass does not usually need to override this method, as it can override write(byte[], int, int) and have write(byte[]) work automatically.
An array of bytes to write to the stream.
An offset into the byte array.
The number of bytes to write.
If any kind of I/O error occurs.
This method writes len bytes of output from the given array, starting at offset off. The method blocks until the bytes are actually written.
The implementation of this method in OutputStream uses write(int) repeatedly to write the bytes. Although it is not strictly necessary, a subclass should override this method to write a block of data more efficiently.
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
equals(Object) |
Object |
finalize() |
Object |
getClass() |
Object |
hashCode() |
Object |
notify() |
Object |
notifyAll() |
Object |
toString() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
ByteArrayOutputStream, FileOutputStream, FilterOutputStream, IOException, ObjectOutputStream, PipedOutputStream