Java 新建、复制、删除、移动文件(夹)操作类(三)

2014-11-24 08:49:28 · 作者: · 浏览: 3

input.close();
}
if (temp.isDirectory()) {// 如果是子文件夹
copyFolder(oldPath + "/ " + file[i], newPath + "/ "
+ file[i]);
}
}
} catch (Exception e) {
System.out.println("复制整个文件夹内容操作出错 ");
e.printStackTrace();

}

}

/**
* 移动文件到指定目录
*
* @param oldPath
* String 如:c:/fqf.txt
* @param newPath
* String 如:d:/fqf.txt
*/
public void moveFile(String oldPath, String newPath) {
copyFile(oldPath, newPath);
delFile(oldPath);

}

/**
* 移动文件夹到指定目录
*
* @param oldPath
* String 如:c:/fqf
* @param newPath
* String 如:d:/fqf
*/
public void moveFolder(String oldPath, String newPath) {
copyFolder(oldPath, newPath);
delFolder(oldPath);
}
}
作者:yhk215492323