Java FileChannel Copy copyFile(File src, File destination)

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

Description

copy File

License

Open Source License

Declaration

public static void copyFile(File src, File destination) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class Main {
    public static void copyFile(File src, File destination) {

        try {/*from www . j  a v a 2s .c o m*/
            if (!destination.exists()) {
                destination.createNewFile();
            }
            FileChannel in = new FileInputStream(src).getChannel();
            FileChannel out = new FileOutputStream(destination).getChannel();
            out.transferFrom(in, 0, in.size());
        } catch (IOException e) {
            e.printStackTrace();

        }
    }
}

Related

  1. copyFile(File src, File dest)
  2. copyFile(File src, File dest)
  3. copyFile(File src, File dest)
  4. copyFile(File src, File dest)
  5. copyFile(File src, File destination)
  6. copyFile(File src, File dst)
  7. copyFile(File src, File dst)
  8. copyFile(File src, File dst)
  9. copyFile(File src, File dst)