java_ buffered stream (input stream of bytes)

. 1   / ** 
2  * java.iko.BufferedInputStream the extends the InputStream
 . 3  * BufferedInputStream: byte input stream buffer
 4  * constructor:
 . 5  * BufferedInputStream (in the InputStream): Create a BufferedInputSream and saves its argument, i.e., the input stream in, for later use
 . 6  * BufferedInputStream (the InputStream in, int size): Create BufferedInputStream with the specified buffer size and saves its argument, i.e., the input stream in, for later use
 7  * parameters:
 . 8  * the InputStream: input stream of bytes
 9  * may be transferred FileInputStream , the buffer flow will increase FileInputStream a buffer, to improve the reading efficiency of FileInputStream
 10  * int size: specifies the size of the internal buffer of the buffer stream, is not specified the default
 11  * use steps:
 12  * 1. Create FileInputStream object constructor binding data source to be read
 13 * 2. Create BufferedInputStream object constructor FileInputStream passing objects, improving the efficiency of
 14  * 3. BufferdInputStream read method reads the file object
 15  * 4. Release the resources
 16   * / 
. 17   public  static  void main (String [] args) throws {IOException
 18 is       // 1. Create FileInputStream object constructor bound data source to be read 
. 19       FileInputStream FIS = new new FileInputStream ( "F.: \\ \\ 1.txt FileTest" );
 20 is       // 2. Create BufferedInputStream object constructor FileInputStream passing objects, efficiency 
21 is       BufferedInputStream BIS = new new BufferedInputStream (FIS);
 22 is       //3. BufferdInputStream read method reads the file object 
23 is       int len = 0 ;
 24       the while ((len = bis.read ()) = -. 1! ) {
 25           System.out.println (len);
 26 is       }
 27       // 4. release the resources 
28       bis.close ();
 29   }

 

Guess you like

Origin www.cnblogs.com/aikang525/p/11288773.html