BufferedInputStream in Java

BufferedInputStream uses mark and reset methods to move backward in the buffered input stream. The mark( ) method sets the return point in the stream. It takes an integer value that specifies the number of bytes that can be read before the stream gives up and forgets about the mark. The reset( ) method returns the stream to the marked point; any data read after the call to mark( ) is read again.

The bufferedInputStream is derived from InputStream class.

Example:
/**
From BufferedInpuStreams.java
*/

import java.io.BufferedInputStream;
import java.io.FileInputStream;

/**
 *
 * @author JavaHotSpot
 */
public class BufferedInpuStreams
{
    public static void main(String args[])
    {
        try
        {
            int i;
            byte b[]=new byte[1000];
            FileInputStream fins = new FileInputStream("C:\\file.txt");
            BufferedInputStream buff = new BufferedInputStream(fins);
            i=buff.read(b);
            System.out.println("File Content is \n"+new String(b,0,i));
        }
        catch(Exception ex)
        {
            System.err.println(ex);
        }
    }

}

Output:
File Content is
A stream represents a flow of data,
or a channel of communication with a
writer at one end and a reader at the other.