There are several methods available in InputStream for basic input needs. The table below lists them.
Method |
Description |
| int read() |
Reads a single byte of data from the stream. The return value is the byte read as an int or -1 if the end of the stream was reached. |
| int read(byte[]) |
Reads data into an array of bytes. The number of bytes read is determined by the length of the byte array passed as an argument. The return value is the number of bytes read or -1 if the end of the stream was reached. |
| int read(byte[], int, int) |
Reads data into an array of bytes starting at a specific location in the array for a certain number of bytes. The return value is the number of bytes read or -1 if the end of the stream was reached. |
| long skip(long) |
Jumps over the specified number of bytes in the stream. The actual number of bytes skipped is returned from this method. Note that this implementation of skip() casts the long passed as a parameter to an int before the skip is performed. It is the job of derived classes to override the default implementation to support skipping larger increments. |
| int available() |
Returns the number of bytes that can be read without blocking. |
| mark(int) |
Positions a placeholder at the current position in the stream that can be returned to later by calling reset() and sets the maximum number of bytes that can be read before the mark is invalidated. Because not all input streams support marking, markSupported() should be called first to determine whether marking is supported by the current input stream if the type of stream is unknown at runtime. |
| boolean markSupported() |
Returns an indication of the current input stream's capability to support marking. |
| reset() |
Returns the current position in the stream to the location set in the previous call to mark() . If the number of bytes read since the last mark() has exceeded the limit, an IOException is thrown. |
| close() |
Closes the input stream and releases any resources allocated by the stream. |