Java FileChannel Copy copyFiles(File source, File dest)

Here you can find the source of copyFiles(File source, File dest)

Description

copy Files

License

Open Source License

Declaration

public static void copyFiles(File source, File dest) 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 void copyFiles(File source, File dest) throws IOException {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        try {/*www.  jav a2 s  .  c o m*/
            fis = new FileInputStream(source);
            fos = new FileOutputStream(dest);
            FileChannel fichannel = fis.getChannel();
            FileChannel foChannel = fos.getChannel();

            long size = fichannel.size();
            fichannel.transferTo(0, size, foChannel);
        } finally {
            if (fis != null) {
                fis.close();
            }
            if (fos != null) {
                fos.close();
            }
        }
    }
}

Related

  1. copyFileLocking(File copyFrom, File copyTo)
  2. copyFileNIO(File src, File dest)
  3. copyFileNio(File src, File dst)
  4. copyFileOrDirectory(File source, File destination, boolean flag)
  5. copyFiles(File originalFile, File destinationFile)
  6. copyFiles(File srcFile, File dstFile, boolean overwrite)
  7. copyFiles(final File fromFile, final File toFile)
  8. copyFileToDir(File file, File destDir)
  9. copyFileToDirectory(String fileFrom, String destinationDirectory)