InputStream

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

Methods from InputStream

int available()
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
void close()
Closes this input stream and releases any system resources associated with the stream.
void mark(int readlimit)
Marks the current position.
boolean markSupported()
if this input stream supports the mark and reset methods.
abstract int read()
Reads the next byte.
int read(byte[] b)
Reads some number of bytes and stores them into the buffer array b.
int read(byte[] b, int off, int len)
Reads up to len bytes of data into an array of bytes.
void reset()
Repositions this stream to the position at the time the mark method was last called.
long skip(long n)
Skips over and discards n bytes.

Revised from Open JDK source code

Home 
  Java Book 
    File Stream