package quickstart;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* Created by patkritLee on 2017/3/21.
*/
public class TestPicDemo {
public static void main(String[] agrs){
FileOutputStream fos = null;
FileInputStream fis = null;
try{
fos = new FileOutputStream("C:\\Users\\patkritLee\\Desktop\\20173770_copy.JPG");
fis = new FileInputStream("C:\\Users\\patkritLee\\Desktop\\20173770.JPG");
byte[] buf = new byte[1024];
int len = 0;
while((len = fis.read(buf))!=-1){
fos.write(buf,0,len);
}
}catch (IOException e){
throw new RuntimeException("复制出现错误!");
}finally {
try{
if(fis!=null){
fis.close();
}
}catch (IOException e){
throw new RuntimeException("读取关闭失败!");
}
try{
if(fos!=null){
fos.close();
}
}catch (IOException e){
throw new RuntimeException("写入关闭失败!");
}
}
}
}