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.

CrossRef.eps The BufferedInputStream class is one of many Java I/O classes that use streams. For more information, see Streams (Overview).

Constructor

Constructor

Description

BufferedInputStream (InputStream in)

Creates a buffered input stream from any object that extends the InputStream class. Typically, you pass this constructor a FileInputStream object.

Methods

Method

Description

int available()

Returns the number of bytes available in the input stream.

void close()

Closes the file.

int read()

Reads a single character from the input stream and returns it as an integer. The method returns –1 if the end of the file has been reached. It throws IOException.

int read(char[] buf, int offset, int max)

Reads multiple characters into an array. Offset provides an offset into ...

Get Java For Dummies Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.