Java Folder Copy nio copyFolder(String path, String resultPath)

Here you can find the source of copyFolder(String path, String resultPath)

Description

copy Folder

License

Open Source License

Declaration

public static boolean copyFolder(String path, String resultPath) 

Method Source Code

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

import java.io.*;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

public class Main {
    public static boolean copyFolder(String path, String resultPath) {
        File file = new File(path);
        File result = new File(resultPath);
        try {/* w  w w  . j  a va  2  s .  c o m*/
            Files.copy(file.toPath(), result.toPath(), StandardCopyOption.REPLACE_EXISTING);
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }
        if (file.isDirectory()) {
            for (File other : file.listFiles()) {
                if (!copyFolder(other.getPath(), result.getPath() + "\\" + other.getName()))
                    return false;
            }
        }
        return true;
    }
}

Related

  1. copyFolder(File sourceFolder, File destinationFolder, List blacklist)
  2. copyFolder(File src, File dest)
  3. copyFolder(File src, File dest)
  4. copyFolder(File src, File dst, FilenameFilter filter)
  5. copyFolder(final File from, final File to)
  6. copyFolderNio(String oldpathall, String newpath)
  7. copyFolders(File sourceFolder, File destFolder)