Java IO stream

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.