package com.jr.ch19;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Copy {
//复制图片
public static void main(String[] args) {
// TODO Auto-generated method stub
FileInputStream fis=null;
FileOutputStream fos=null;
try {
fis=new FileInputStream("F:/IO/potho/pear.jpg");
byte [] b=new byte[fis.available()];
fis.read(b);
fos=new FileOutputStream("E:/potho3/pear3.jpg");
fos.write(b);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
if(fis!=null){
fis.close();
}
if(fos!=null){
fos.flush();
fos.close();
}
} catch (Exception e2) {
// TODO: handle exception
}
}
}
}
复制不要求在同一个目录下。
Java中字节流复制图片FileInputStream FileOutputStream
最新推荐文章于 2024-03-13 08:06:06 发布