Java Folder Copy nio copyFolderNio(String oldpathall, String newpath)

Here you can find the source of copyFolderNio(String oldpathall, String newpath)

Description

copy Folder Nio

License

Open Source License

Declaration

public static void copyFolderNio(String oldpathall, String newpath) throws IOException 

Method Source Code

//package com.java2s;

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 copyFolderNio(String oldpathall, String newpath) throws IOException {
        String newpathall = newpath + File.separator + new File(oldpathall).getName();
        FileChannel inputChannel = null;
        FileChannel outputChannel = null;
        try {/*from   ww  w  .ja v  a 2  s  .  co  m*/
            inputChannel = new FileInputStream(oldpathall).getChannel();
            outputChannel = new FileOutputStream(newpathall).getChannel();
            outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
        } finally {
            inputChannel.close();
            outputChannel.close();
        }
    }
}

Related

  1. copyFolder(File src, File dest)
  2. copyFolder(File src, File dest)
  3. copyFolder(File src, File dst, FilenameFilter filter)
  4. copyFolder(final File from, final File to)
  5. copyFolder(String path, String resultPath)
  6. copyFolders(File sourceFolder, File destFolder)