Io is divided into two streams: byte stream and bytes stream.

Source: Internet
Author: User

Io is divided into two streams: byte stream and bytes stream.


1. byte stream inputstream outputstream

2. Producer stream reader writer

The above four classes are all abstract classes.

Specific implementation:
The implementation of byte stream is: fileinputstream fileoutputstream
The implementation of the upload stream is: filereader filewriter

You can use inputsteamreader outputstreamwriter to convert byte streams into bytes streams.

Then process the shard stream: convert it to bufferdreader bufferedwriter, so that it has a buffer

The implementation of byte Transfer into streams is as follows:

 
Fileinputstream = new fileinputstream ("C:/text.txt"); // defines the inputstreamreader = new inputstreamreader (fileinputstream), a byte stream pointing to C:/testtxt ); // change byte stream to inputstreamreaderbufferedreader bufferedreader = new bufferedreader (inputsteamreader); // convert inputstreamreader to bufferedreader with Cache

Assign the read content to the character.

 
String Ss = new string (); string s; while (S = bufferedreader. Readline ())! = NULL) {SS + = s ;}

Example: byte streams are sent to the upstream stream, and then the upstream stream has a buffer zone.

 
Fileoutputstream = new fileoutputstream ("C:/test.txt"); // defines a byte stream that points to C:/test.txt outputstreamwriter = new outputstreamwriter (fileoutputstream ); // byte Transfer bytes stream bufferedwriter = new bufferedwriter (outputstreamwriter); // enable the bytes stream to have a buffer bufferedwriter. write (s); bufferedwriter. close (); outputstreamwriter. close (); fileoutputstream. close ();


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.