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 Class | Meaning |
---|---|
BufferedInputStream | Buffered input stream |
BufferedOutputStream | Buffered output stream |
ByteArrayInputStream | Input stream that reads from a byte array |
ByteArrayOutputStream | Output stream that writes to a byte array |
DataInputStream | An input stream that contains methods for reading the Java standard data types |
DataOutputStream | An output stream that contains methods for writing the Java standard data types |
FileInputStream | Input stream that reads from a file |
FileOutputStream | Output stream that writes to a file |
FilterInputStream | Implements InputStream |
FilterOutputStream | Implements OutputStream |
InputStream | Abstract class that describes stream input |
ObjectInputStream | Input stream for objects |
ObjectOutputStream | Output stream for objects |
OutputStream | Abstract class that describes stream output |
PipedInputStream | Input pipe |
PipedOutputStream | Output pipe |
PrintStream | Output stream that contains print( ) and println( ) |
PushbackInputStream | Input stream that supports one-byte "unget," which returns a byte to the input stream |
RandomAccessFile | Supports random access file I/O |
SequenceInputStream | Input 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