BufferedInputStream Class
Package: java.io
The BufferedInputStream
class reads characters from an input stream, using a buffer for increased efficiency. (A buffer is a temporary storage area that allows your program to read a large amount of data from disk at one time, and then hold it there until your program needs it.)
Note that you won’t typically work directly with the Buffered InputStream
class. Instead, you’ll use it to connect to a DataInputStream
, which has more advanced features for reading input data from binary files. For more information, see DataInputStream Class.
Constructor
Constructor |
Description |
|
Creates a buffered input stream from any object that extends the |
Methods
Method |
Description |
|
Returns the number of bytes available in the input stream. |
|
Closes the file. |
|
Reads a single character from the input stream and returns it as an integer. The method returns |
|
Reads multiple characters into an array. |
|
Skips ahead the specified number of characters. |
Creating a BufferedInputStream object
A BufferedInputStream
is usually created from a File InputStream
, which is in turn created from a File
. For example:
File f;
FileInputStream fstream;
BufferedInput in;
f = new File(“myfile.txt”);
fstream = new FileInputStream(f);
in = new BufferedInputStream(fstream);