OutputStream

The Byte Stream Classes

Byte streams are defined by using two class hierarchies. At the top are two abstract classes: InputStream and OutputStream.

Stream ClassMeaning
BufferedInputStreamBuffered input stream
BufferedOutputStreamBuffered output stream
ByteArrayInputStreamInput stream that reads from a byte array
ByteArrayOutputStreamOutput stream that writes to a byte array
DataInputStreamAn input stream that contains methods for reading the Java standard data types
DataOutputStreamAn output stream that contains methods for writing the Java standard data types
FileInputStreamInput stream that reads from a file
FileOutputStreamOutput stream that writes to a file
FilterInputStreamImplements InputStream
FilterOutputStreamImplements OutputStream
InputStreamAbstract class that describes stream input
ObjectInputStreamInput stream for objects
ObjectOutputStreamOutput stream for objects
OutputStreamAbstract class that describes stream output
PipedInputStreamInput pipe
PipedOutputStreamOutput pipe
PrintStreamOutput stream that contains print( ) and println( )
PushbackInputStreamInput stream that supports one-byte "unget," which returns a byte to the input stream
RandomAccessFileSupports random access file I/O
SequenceInputStreamInput stream that is a combination of two or more input streams that will be read sequentially, one after the other

This abstract class is the superclass of all classes representing an output stream of bytes. An output stream accepts output bytes and sends them to some sink. Applications that need to define a subclass of OutputStream must always provide at least a method that writes one byte of output.

void close()
Closes this output stream and releases any system resources associated with this stream.
void flush()
Flushes this output stream and forces any buffered output bytes to be written out.
void write(byte[] b)
Writes b.length bytes from the specified byte array to this output stream.
void write(byte[] b, int off, int len)
Writes len bytes from the specified byte array starting at offset off to this output stream.
abstract void write(int b)
Writes the specified byte to this output stream.

Revised from Open JDK source code

Home 
  Java Book 
    File Stream