标签:imp lis exception 复制 输入 tput rac [] put
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
//文件复制
//E:/3.jpg ---> D:/1.jpg
public class CopyFileByIo {
public static void main(String[] args) {
FileInputStream fis=null;
FileOutputStream fos=null;
try {
//输入流读取 E:/3.jpg
fis=new FileInputStream("E:/3.jpg");
//输出流
fos=new FileOutputStream("D:/1.jpg");
//字节缓冲区
byte[] buffer=new byte[1024];
int len=0;
while((len=fis.read(buffer))!=-1){
fos.write(buffer, 0, len);
fos.flush();
}
System.out.println("复制成功!");
} catch (Exception e) {
e.printStackTrace();
} finally{
try {
fos.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
标签:imp lis exception 复制 输入 tput rac [] put
原文地址:http://www.cnblogs.com/sundy-HOME/p/6847621.html