public void copyFile(String oldPath, String newPath) {
final int BUF_LEN = 4096;
int bytesum = 0;
int byteread = 0;
File oldfile = new File(oldPath);
File newFile = new File(newPath);
InputStream inStream = null;
FileOutputStream fs = null;
if (!oldfile。
exists() || Directory()) {
intln("源文件不存在或者是目录:" + oldPath);
return;
}
if (newFile。
exists() && File()) {
intln("目标文件已经存在,不能覆盖:" + newPath);
return;
}
try {
inStream = new FileInputStream(oldPath); //读入原文件
fs = new FileOutputStream(newPath);
byte[] buffer = new byte[BUF_LEN];
while ((byteread = ad(buffer, 0, BUF_LEN)) > 0) {
bytesum += byteread; //字节数 文件