。。。 Io Stream Learning II ...

Source: Internet
Author: User

Usage of FileReader:

1 Import Staticorg.junit.assert.*;2 3 ImportJava.io.File;4 Importjava.io.FileNotFoundException;5 ImportJava.io.FileReader;6 ImportJava.io.FileWriter;7 Importjava.io.IOException;8 9 Importorg.junit.Test;Ten  One ImportCom.sun.org.apache.bcel.internal.generic.NEW; A  -  -  the  -  Public classMyTest { -     //writes data to a specified file by a character stream - @Test +      Public voidTestwrite ()throwsIOException { -String Path = "F:" +file.separator+ "Demo.txt"; +FileReader FileReader =NULL; A         Try { atFileReader =NewFileReader (path); -             Char[] buf =New Char[10]; -             intTemp =0; - //FileReader to read 10 characters, and put the read character into the BUF array, the actual number of characters to supervise the existence of a temp -              while(temp = Filereader.read (buf))!=-1){ -System.out.println (NewString (buf,0, temp)); in             } -              to}Catch(FileNotFoundException e) { +             //TODO auto-generated Catch block - e.printstacktrace (); the         } *          $         Panax Notoginseng     } -  the}



char[] buf = new char[100];

。。。 Io Stream Learning II ...

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.