Here you can find the source of copyFile(File source, File destination)
Copies single file to new location borrowed from: http://www.crazysquirrel.com/computing/java/basics/java-file-and-directory-copying.jspx
Parameter | Description |
---|---|
source | a parameter |
destination | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static final void copyFile(File source, File destination) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.channels.FileChannel; public class Main { /** Copies single file to new location * borrowed from: http://www.crazysquirrel.com/computing/java/basics/java-file-and-directory-copying.jspx * @param source/*www . ja v a2s . co m*/ * @param destination * @throws IOException */ public static final void copyFile(File source, File destination) throws IOException { FileChannel sourceChannel = new FileInputStream(source).getChannel(); FileChannel targetChannel = new FileOutputStream(destination).getChannel(); sourceChannel.transferTo(0, sourceChannel.size(), targetChannel); sourceChannel.close(); targetChannel.close(); } }