Java FileChannel Copy copyFileUsingChannel(File source, File dest)

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

Description

copy File Using Channel

License

Creative Commons License

Declaration

public static void copyFileUsingChannel(File source, File dest) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

import java.io.*;
import java.nio.channels.FileChannel;

public class Main {
    public static void copyFileUsingChannel(File source, File dest) throws IOException {

        FileInputStream sourceStream = new FileInputStream(source);
        FileChannel sourceChannel = sourceStream.getChannel();
        FileOutputStream outputStream = new FileOutputStream(dest);
        outputStream.getChannel().transferFrom(sourceChannel, 0, sourceChannel.size());
    }/* w  ww.  j  a  v  a  2  s  .  c  o  m*/
}

Related

  1. copyFileToDir(File file, File destDir)
  2. copyFileToDirectory(String fileFrom, String destinationDirectory)
  3. copyFileToFolder(final String resultFile, final String targetPath)
  4. copyFileToStream(File in, OutputStream out)
  5. copyFileUsingChannel(File source, File dest)
  6. copyFileUsingFileChannels(File source, File dest)
  7. copyFileUsingFileChannels(File source, File dest)
  8. copyFileUsingFileChannels(File source, File dest)
  9. copyFolder(File fin, File fout)