移动文件
复制文件
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;
}
复制文件
private void copyFile(File in, File out) throws Exception{
FileChannel sourceChannel= new FileInputStream(in).getChannel();
FileChannel destinationChannel= new FileOutputStream(out).getChannel();
sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
// or
// destinationChannel.transferFrom(sourceChannel, 0,
// sourceChannel.size());
sourceChannel.close();
destinationChannel.close();
sourceChannel= null;
destinationChannel= null;
}