Java FileChannel Copy copyTransfer(String srcPath, String destPath)

Here you can find the source of copyTransfer(String srcPath, String destPath)

Description

copy Transfer

License

Open Source License

Declaration

public static void copyTransfer(String srcPath, String destPath)
        throws IOException 

Method Source Code

//package com.java2s;
/*//  w  w w . j  a va 2s  .  c  om
 * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
 * All rights reserved. This program is made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 * Contributors:
 * General Robotix Inc.
 * National Institute of Advanced Industrial Science and Technology (AIST) 
 */

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

public class Main {

    public static void copyTransfer(String srcPath, String destPath)
            throws IOException {

        FileChannel srcChannel = new FileInputStream(srcPath).getChannel();
        FileChannel destChannel = new FileOutputStream(destPath)
                .getChannel();
        try {
            srcChannel.transferTo(0, srcChannel.size(), destChannel);
        } finally {
            srcChannel.close();
            destChannel.close();
        }
    }
}

Related

  1. copyThrowsOnException(final File source, final File destination)
  2. copyTo(File srcFile, File destFile)
  3. copyToFolderAs(File fromFile, File folder, String asName)
  4. copyToTemp(File srcFile)
  5. copyToTempDirectory(final String file)
  6. copyTree(File sourceLocation, File targetLocation)
  7. copyTree(File srcFile, File trgFile)
  8. copyTree(final File source, final File dest)
  9. copyURLToFile(URL in, File out)