A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the  and reset methods. When the BufferedInputStream is created, an internal buffer array is created. As bytes from the stream are read or skipped, the internal buffer is refilled as necessary from the contained input stream, many bytes at a time. The  operation remembers a point in the input stream and the reset operation causes all the bytes read since the most recent  operation to be reread before new bytes are taken from the contained input stream.
BufferedInputStream(InputStream in) 
          Creates a BufferedInputStream and saves its argument, the input stream in, for later use. 
BufferedInputStream(InputStream in, int size) 
          Creates a BufferedInputStream with the specified buffer size, and saves its argument, the input stream in, for later use. 
  Method Summary 
 int available() 
          Returns the number of bytes that can be read from this input stream without blocking. 
 void close() 
          Closes this input stream and releases any system resources associated with the stream. 
 void (int readlimit) 
          See the general contract of the  method of InputStream. 
 boolean Supported() 
          Tests if this input stream supports the  and reset methods. 
 int read() 
          See the general contract of the read method of InputStream. 
 int read(byte[] b, int off, int len) 
          Reads bytes from this byte-input stream into the specified byte array, starting at the given offset. 
 void reset() 
          See the general contract of the reset method of InputStream. 
 long skip(long n) 
          See the general contract of the skip method of InputStream. 
看下DOC不就什么都明白了吗

解决方案 »

  1.   

    为提高速度,最好先对文件进行缓冲处理,从而获得用于一个BufferedInputStream的构建器的结果句柄。BufferedInputStream 避免每次想要更多数据时都进行物理性的读取,告诉它“请先在缓冲区里找”。BufferedInputStream(InputStream in) 
    BufferedInputStream(InputStream in, int size)
      

  2.   

    首先,缓冲区概念:一片内存存储空间,在读写数据的程序需要之前,数据存储在这里,这样就不用每次去物理硬盘上的数据源取了。(快嘛!)
          缓冲输入流(BufferedInputStream):顾名思义,是在缓冲区取数据的输入流(InputStream)。输入流都是在硬盘数据源去数据的。要从缓冲区取数据,那缓冲区里面要有数据的,对吧?谁写进去呢?当然是输入流(InputStream)了,所以要建立缓冲输入流(BufferedInputStream),必须指定一个输入流。          FileInputStream instr=new FileInputStream("girlsjj.dat");
       FileInputStream是InputStream的子类,表示从一个硬盘上的文件girlsjj.dat中取数据。
      于是 BufferedInputStream buff=new BufferedInputStream(instr);
      然后,你就可以使用buff来读取数据了。
          buff.read();   //读的具体细节看看书。以上表示girlsjj.dat文件中的数据先写入内存中的缓冲区,然后从缓冲区里读到程序中。 同时你还可以指定缓冲区的大小:BufferedInputStream(InputStream,int)
        //大小为int的缓冲区。