Java FileChannel Copy copyFile(File source, File destination)

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

Description

copy File

License

Open Source License

Declaration

public static final void copyFile(File source, File destination)
            throws IOException 

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 final void copyFile(File source, File destination)
            throws IOException {
        FileChannel sourceChannel = new FileInputStream(source)
                .getChannel();//  w w  w .  j  a va 2s.co  m
        FileChannel targetChannel = new FileOutputStream(destination)
                .getChannel();
        sourceChannel.transferTo(0, sourceChannel.size(), targetChannel);
        sourceChannel.close();
        targetChannel.close();
    }
}

Related

  1. copyFile(File source, File destination)
  2. copyFile(File source, File destination)
  3. copyFile(File source, File destination)
  4. copyFile(File source, File destination)
  5. copyFile(File source, File destination)
  6. copyFile(File source, File destination)
  7. copyFile(File source, File destination, boolean overwrite)
  8. copyFile(File source, File destination, long chunkSize, boolean overwrite)
  9. copyFile(File source, File target)