Java File Copy nio copy(File source, File destination)

Here you can find the source of copy(File source, File destination)

Description

Copys a file

License

LGPL

Parameter

Parameter Description
source Sourcefile
destination Destination of copy

Exception

Parameter Description
IOException an exception

Declaration

public static void copy(File source, File destination) throws IOException 

Method Source Code

//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);
    }
}

Related

  1. copy(File source, File dest)
  2. copy(File source, File dest, boolean preserveTime)
  3. copy(File source, File destination)
  4. copy(File source, File destination)
  5. copy(File source, File destination)
  6. copy(File source, File destination)
  7. copy(File source, File destination)
  8. copy(File source, File target)
  9. copy(File source, File target)