Java之输出输入流实现文件的复制
慢慢的开始写博客了!
或许这是一个好的开始
慢慢的练习自己就很好了。代码慢慢理解
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("读取完成!");
}
}
前后复制的图片对比
看的出来图片已经复制成功了!!