使用java復(fù)制移動(dòng)文件
Posted on 2005-11-17 16:03 Terry的Blog 閱讀(5262) 評(píng)論(2) 編輯 收藏 所屬分類: java語(yǔ)言 /**
* Moving a File to Another Directory
* @param srcFile eg: c:\windows\abc.txt
* @param destPath eg: c:\temp
* @return success
*/
public static boolean move(String srcFile, String destPath){
// File (or directory) to be moved
File file = new File(srcFile);
// Destination directory
File dir = new File(destPath);
// Move file to new directory
boolean success = file.renameTo(new File(dir, file.getName()));
return success;
}
* Moving a File to Another Directory
* @param srcFile eg: c:\windows\abc.txt
* @param destPath eg: c:\temp
* @return success
*/
public static boolean move(String srcFile, String destPath){
// File (or directory) to be moved
File file = new File(srcFile);
// Destination directory
File dir = new File(destPath);
// Move file to new directory
boolean success = file.renameTo(new File(dir, file.getName()));
return success;
}