Java:io Stream (leak filling)

Source: Internet
Author: User

The buffer in the 1.IO stream is too small, which will cause the read incomplete (the printed things will not be all) read in will be the last read, will not cause write incomplete (that is written out of things).
2. The role of a buffer in reading is to read the contents of a file into the buffer, and then through the buffer to store, the buffer is too small will cause the printing is not complete.
Buffer in the output, as a medium, read into the buffer how much output, sequentially loop, and ultimately all printing.
3. Four ways to write:
A.
int Len;
while (((Len=fis.read ())!=-1) {
Fos.write ();
}

B.
Byte[] Byt=new byte[1024];
int Len;
while ((Len=fis.read (Byt,0,byt.length ())!=-1) {
Fos.write (Byt,0,len); No space behind, precise output
}
C.
Byte[] Byt=new byte[1024];
int Len;
while ((Len=fis.read (Byt,0,byt.length ())!=-1) {
Fos.write (Byt,0,byt.length ()); There are a lot of spaces behind, larger range
}
D.
Byte[] Byt=new byte[1024];
int Len;
while ((Len=fis.reade (byt))!=-1) {
Fos.write (BYT); There are a lot of spaces behind, larger range
}

Java:io Stream (leak filling)

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.