/**
*
* @param oldPathFile 精确到文件名
* @param newPathFile 精确到文件名
* @throws Exception
*/
public static void copyFile(String oldPathFile, String newPathFile)throws Exception {
int bytesum = 0;
int byteread = 0;
File oldfile = new File(oldPathFile);
if (oldfile.exists()) { //文件存在时
InputStream inStream = new FileInputStream(oldPathFile); //读入原文件
FileOutputStream fs = new FileOutputStream(newPathFile);
byte[] buffer = new byte[1444];
int length;
while ( (byteread = inStream.read(buffer)) != -1) {
bytesum += byteread; //字节数 文件大小
//System.out.println(bytesum);
fs.write(buffer, 0, byteread);
}
inStream.close();
}
}
转载于https://www.cnblogs.com/zouhao/p/12958617.html