Java FileChannel Copy copyFile(String srcFileName, String desFileName)

Here you can find the source of copyFile(String srcFileName, String desFileName)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(String srcFileName, String desFileName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.nio.channels.FileChannel;

public class Main {

    public static void copyFile(String srcFileName, String desFileName) {
        try {//from www.java2 s .  c  om
            FileChannel srcChannel = new FileInputStream(srcFileName).getChannel();

            FileChannel dstChannel = new FileOutputStream(desFileName).getChannel();

            dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

            srcChannel.close();
            dstChannel.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. copyFile(String source, String target)
  2. copyFile(String sourceFile, String destFile)
  3. copyFile(String sourceFilename, String destFilename)
  4. copyFile(String sourceFileName, String destinationFileName)
  5. copyFile(String src, String dest)
  6. copyFile(String srcPath, String destPath)
  7. copyFileByChannel(String srcFileName, String dstFileName)
  8. copyFileContent(final String sourcePath, final String targetPath)
  9. copyFileIntoProjectFolder(String projectName, File file)