The Byte Streams
The byte stream classes handles byte-oriented I/O. The byte stream classes are topped by InputStream and OutputStream.
InputStream
InputStream is an abstract class that defines Java's model of streaming byte input. It implements the Closeable interface.
Most of the methods in this class will throw an IOException on error conditions.
int available( )
- Returns the number of bytes of input currently available for reading.
void close( )
- Closes the input source.
void mark(int numBytes)
- Places a mark at the current point that will remain valid until numBytes bytes are read.
boolean markSupported( )
- Returns true if mark( )/reset( ) are supported by the invoking stream.
int read( )
- Returns an integer representation of the next available byte of input. -1 is returned if file ends.
int read(byte buffer[ ])
- Read up to buffer.length bytes into buffer and returns the actual number of bytes that were successfully read. -1 is returned when the end of the file is encountered.
int read(byte buffer[ ], int offset, int numBytes)
- Read up to numBytes bytes into buffer starting at buffer[offset], returning the number of bytes successfully read. -1 is returned when the end of the file is encountered.
void reset( )
- Resets the input pointer to the previously set mark.
long skip(long numBytes)
- Skip numBytes bytes of input, returning the number of bytes actually ignored.
OutputStream
OutputStream is an abstract class that defines streaming byte output. It implements the Closeable and Flushable interfaces.
Methods from OutputStream
void close( )
- Closes the output stream.
void flush( )
- Flushes the output state so that any buffers are cleared.
void write(int b)
- Writes a single byte to an output stream.
void write(byte buffer[ ])
- Writes a complete array of bytes to an output stream.
void write(byte buffer[ ], int offset, int numBytes)
- Writes a subrange of numBytes bytes from the array buffer, beginning at buffer[offset].