Java FileChannel Copy fileChannelCopy(File src, File dest)

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

Description

file Channel Copy

License

Open Source License

Declaration

public static void fileChannelCopy(File src, File dest) 

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 fileChannelCopy(File src, File dest) {
        FileInputStream fi = null;
        FileOutputStream fo = null;
        FileChannel in = null, out = null;
        try {//www  .  jav  a 2 s  .  c  om
            fi = new FileInputStream(src);
            fo = new FileOutputStream(dest);
            in = fi.getChannel();
            out = fo.getChannel();
            in.transferTo(0, in.size(), out);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fi.close();
                in.close();
                fo.close();
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Related

  1. directoryCopy(URL source, URL destination)
  2. doCopyDirectory(File srcDir, File destDir, boolean preserveFileDate, List exclusionList)
  3. doCopyFile(File srcFile, File destFile, boolean preserveFileDate)
  4. doCopyFile(File srcFile, File destFile, boolean preserveFileDate)
  5. fCopy(FileInputStream src, File dest)
  6. fileCopy(String sourceFolder, String destinationFolder)
  7. fileStreamCopy(FileInputStream in, FileOutputStream out, boolean closeOutput)
  8. nioCopy(File source, File target, FilenameFilter filter)
  9. nioCopy(FileOutputStream fos, FileInputStream fis)