/**
*
* @param source
* 源文件
* @param dest
* 目标文件
* @param isCut
* 是否剪切
* @throws IOException
*/
public static void copyFile(File source, File dest, boolean isCut)
throws IOException {
boolean exists = dest.exists();
if (!exists)
dest.createNewFile();
FileChannel in = null;
FileChannel out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
in.transferTo(0, in.size(), out);
} finally {
if (in != null) {
try {
in.close();
} catch (Throwable t) {
}
}
if (out != null)
out.close();
}
dest.setLastModified(source.lastModified());
if (isCut)
source.delete();
}
*
* @param source
* 源文件
* @param dest
* 目标文件
* @param isCut
* 是否剪切
* @throws IOException
*/
public static void copyFile(File source, File dest, boolean isCut)
throws IOException {
boolean exists = dest.exists();
if (!exists)
dest.createNewFile();
FileChannel in = null;
FileChannel out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
in.transferTo(0, in.size(), out);
} finally {
if (in != null) {
try {
in.close();
} catch (Throwable t) {
}
}
if (out != null)
out.close();
}
dest.setLastModified(source.lastModified());
if (isCut)
source.delete();
}