Copy File in Java
Copy disk file:
private void copyFile(String fromDir, String todir, String frfile, String tofile) {
String fromFile = fromDir + sep + frfile;
String outFileName = todir + sep + tofile;
try {
FileChannel src = new FileInputStream(fromFile).getChannel();
FileChannel dst = new FileOutputStream(outFileName).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
log.info("Created file: " + outFileName);
} catch (IOException e) {
log.error("Error copying file " + frfile + " from " + fromDir, e);
}
}
0 Comments:
Post a Comment
<< Home