package com.cn;
import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;
import java.io.OutputStream;
/**
* 复制文件类 * 创建者 : xxx * 创建日期: 2018年06月12日 */public class copyFileTest{
/**
* 复制文件 * 创建者 : xxx * 创建日期: 2018年06月12日 * @param fromFile //源文件路径 * @param toFile //新文件路径 * @throws IOException 异常 */ public static boolean copyFile(File fromFile,File toFile) throws IOException{ FileInputStream ins = new FileInputStream(fromFile); FileOutputStream out = new FileOutputStream(toFile); byte[] b = new byte[1024]; int n=0; while((n=ins.read(b))!=-1){ out.write(b, 0, n); } ins.close(); out.close();}
}