Here you can find the source of copy(File source, File destination)
Copys a file
Parameter | Description |
---|---|
source | Sourcefile |
destination | Destination of copy |
Parameter | Description |
---|---|
IOException | an exception |
public static void copy(File source, File destination) throws IOException
//package com.java2s; //License from project: LGPL import java.io.*; import java.nio.channels.FileChannel; public class Main { /**//from ww w .ja v a 2 s . c o m * <p>Copys a file</p> * @param source Sourcefile * @param destination Destination of copy * @throws IOException */ public static void copy(File source, File destination) throws IOException { //File in = new File(source); //File out = new File(destination); FileChannel inChannel = new FileInputStream(source).getChannel(); FileChannel outChannel = new FileOutputStream(destination).getChannel(); inChannel.transferTo(0, inChannel.size(), outChannel); } }