No, there is no built-in method to do that. The closest to what you want to accomplish is the transferFrom
method from FileOutputStream
, like so:
FileChannel src = new FileInputStream(file1).getChannel();
FileChannel dest = new FileOutputStream(file2).getChannel();
dest.transferFrom(src, 0, src.size());
And don't forget to handle exceptions and close everything in a finally
block.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…