文件拷贝

import java.io.*;


public class FileUtil {
    public static  void copy(File src,File dest){
        FileInputStream fis=null;
        FileOutputStream fos=null;
        try {
            byte[] bys = new byte[1024];
            int size = -1;
            fis = new FileInputStream(src);
            fos = new FileOutputStream(dest);
            while((size=fis.read(bys))!=-1){
                fos.write(bys);
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally{
            try {
                fis.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                fos.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

}

 

posted on 2016-01-06 23:07  编世界  阅读(138)  评论(0编辑  收藏  举报