Copy the Java input stream to achieve the output file

Slowly I began to write a blog!

Perhaps this is a good start

Slowly practice their fine. Slowly understand the code

package com.Grap;


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.Buffer;


public class Readfile {
public static void main(String[] args) throws Exception {
FileInputStream in=new FileInputStream("G:\\谷歌下载\\shana.png");
FileOutputStream on=new FileOutputStream("G:\\sha.jpg");
BufferedInputStream buffin=new BufferedInputStream(in);
BufferedOutputStream buffout=new BufferedOutputStream(on);
; int len=0;
byte []b=new byte[10240000];
while((len=buffin.read(b))!=-1){
buffout.write(b, 0, len);
}
buffout.flush();
buffin.close();
buffout.close();
System.out.println("读取完成!");
}


}



Copied pictures before and after comparison 

Look out of the picture has been successfully copied! !

Published 19 original articles · won praise 58 · views 50000 +

Guess you like

Origin blog.csdn.net/cyg_l02/article/details/80343530