/**
* ファイルコピーします。
*
* @param srcPath コピー元
* @param destPath コピー先
*/
public static void copy(File srcPath, File destPath) {
FileChannel srcChannel = null;
FileChannel destChannel = null;
try {
srcChannel = new FileInputStream(srcPath).getChannel();
destChannel = new FileOutputStream(destPath).getChannel();
srcChannel.transferTo(0, srcChannel.size(), destChannel);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (srcChannel != null) {
try {
srcChannel.close();
} catch (IOException e) {
}
}
if (destChannel != null) {
try {
destChannel.close();
} catch (IOException e) {
}
}
}
}
* ファイルコピーします。
*
* @param srcPath コピー元
* @param destPath コピー先
*/
public static void copy(File srcPath, File destPath) {
FileChannel srcChannel = null;
FileChannel destChannel = null;
try {
srcChannel = new FileInputStream(srcPath).getChannel();
destChannel = new FileOutputStream(destPath).getChannel();
srcChannel.transferTo(0, srcChannel.size(), destChannel);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (srcChannel != null) {
try {
srcChannel.close();
} catch (IOException e) {
}
}
if (destChannel != null) {
try {
destChannel.close();
} catch (IOException e) {
}
}
}
}
0 件のコメント:
コメントを投稿