Here you can find the source of copyFile(File fileIn, File fileOut)
Parameter | Description |
---|---|
fileIn | a parameter |
fileOut | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void copyFile(File fileIn, File fileOut) throws IOException
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.io.*; import java.nio.channels.FileChannel; public class Main { /**//from w w w .j a va 2 s . com * @param fileIn * @param fileOut * @throws IOException */ public static void copyFile(File fileIn, File fileOut) throws IOException { FileChannel sourceChannel = null; FileChannel destinationChannel = null; try { sourceChannel = new FileInputStream(fileIn).getChannel(); destinationChannel = new FileOutputStream(fileOut).getChannel(); sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel); } finally { try { if (sourceChannel != null) { sourceChannel.close(); } } finally { if (destinationChannel != null) { destinationChannel.close(); } } } } }