1.java of Bufferreader
The purpose of creating this class is: Because the CPU is much faster than it is, the speed of the file stream is read (directly from the file on the hard disk), in order not to let the CPU idle. The speed is greatly increased by first reading the contents of the file into the height cache, and then letting the CPU read the data from the cache.
Usage
PackageTest.io;ImportJava.io.BufferedReader;ImportJava.io.File;Importjava.io.FileNotFoundException;ImportJava.io.FileReader;Importjava.io.IOException;ImportJava.io.InputStreamReader;ImportJava.io.Reader;Importorg.junit.Test;/** Test character Stream*/ Public classTestreader {@Test Public voidTest () {File file=NewFile ("D://file//aaa.txt"); BufferedReader bu; Char[] Aa=New Char[10]; Try{bu=NewBufferedReader (Newfilereader (file)); String message= ""; //System.out.println (Bu.read ()); while(message = Bu.readline ())! =NULL) { //1 System.out.println (message); } } Catch(FileNotFoundException e) {//TODO auto-generated Catch blockE.printstacktrace (); } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); } }}
Output:
The purpose of this writing at 1:the ReadLine method reads a row, and if no assignment is made, each read will be spaced one line at a time
Output:
Java IO stream