Java Basics (ii)

Source: Internet
Author: User

Basic IO Flow Summary

Java can be divided into:

1, according to the direction of the data flow can be divided into: input stream (inputstream/reader) and output stream (Outputstream/writer) (relative to the point of view of the program)

2, according to the processing data units can be divided into: byte stream and character streams.

3, according to the implementation of different functions can be divided into: node flow and processing flow.

First, the creation of the file:

File File = NewFile ("D:/1.txt");

File.createnewfile ();

Ii. Deletion of documents

File.delete ();

Iii. FileInputStream and FileOutputStream class

File File = NewFile ("D:/1.txt");

FileOutputStream out = newfileoutputstream (file);

Out.write (...);

FileInputStream in= newfileinputstream (file);

In.read (...);

Iv. FileReader and FileWriter classes

File File = NewFile ("D:/1.txt");

FileWriter out = newfilewriter (file);

Out.write (...);

FileReader in = newfilereader (file);

In.read (...);

Five, with cache of input and output stream (with buffer to improve performance)

1, Bufferinputstream and Bufferoutputstream class

File File = NewFile ("D:/1.txt");

FileOutputStream out = newfileoutputstream (file);

Bufferoutputstream bo= Newbufferoutputstream (out);

Bo.write (...);

FileInputStream in= newfileinputstream (file);

Bufferinputstreambi= new Bufferinputstream (out);

Bi.read (...);

2, Bufferreader and Bufferwriter class

File File = NewFile ("D:/1.txt");

FileWriter out = newfilewriter (file);

Bufferwriter bw = Newbufferwriter (out);

Bw.write (...);

FileReader in = newfilereader (file);

Bufferreader br = Newbufferreader (in);

Br.read (...);


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.