Java Utililty Methods Folder Copy nio

List of utility methods to do Folder Copy nio

Description

The list of methods to do Folder Copy nio are organized into topic(s).

Method

voidcopyFolder(File sourceFolder, File destinationFolder)
copy Folder
copyFolder(sourceFolder, destinationFolder, true);
voidcopyFolder(File sourceFolder, File destinationFolder)
copy Folder
if (sourceFolder.isDirectory()) {
    if (!destinationFolder.exists()) {
        destinationFolder.mkdirs();
    String files[] = sourceFolder.list();
    for (String file : files) {
        File srcFile = new File(sourceFolder, file);
        File destFile = new File(destinationFolder, file);
...
voidcopyFolder(File sourceFolder, File destinationFolder, List blacklist)
copy Folder
copyFolder(sourceFolder, destinationFolder, true, blacklist);
voidcopyFolder(File src, File dest)
copy Folder
if (src.isDirectory()) {
    if (!dest.exists()) {
        dest.mkdir();
    String files[] = src.list();
    for (String file : files) {
        File srcFile = new File(src, file);
        File destFile = new File(dest, file);
...
voidcopyFolder(File src, File dest)
copy Folder
if (src.isDirectory()) {
    if (!dest.exists()) {
        dest.mkdir();
    String files[] = src.list();
    for (String file : files) {
        File srcFile = new File(src, file);
        File destFile = new File(dest, file);
...
voidcopyFolder(File src, File dst, FilenameFilter filter)
copy Folder
if (src.isDirectory()) {
    if (!dst.exists()) {
        dst.mkdir();
    String files[] = src.list(filter);
    for (String file : files) {
        File srcFile = new File(src, file);
        File destFile = new File(dst, file);
...
voidcopyFolder(final File from, final File to)
copy a full folder recursively
assert !to.exists() || to.isDirectory();
if (!to.exists()) {
    to.mkdirs();
if (!from.isDirectory()) {
    copy(from.getAbsolutePath(), new File(to, from.getName()).getAbsolutePath());
} else {
    final File newDestDir = new File(to, from.getName());
...
booleancopyFolder(String path, String resultPath)
copy Folder
File file = new File(path);
File result = new File(resultPath);
try {
    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;
voidcopyFolderNio(String oldpathall, String newpath)
copy Folder Nio
String newpathall = newpath + File.separator + new File(oldpathall).getName();
FileChannel inputChannel = null;
FileChannel outputChannel = null;
try {
    inputChannel = new FileInputStream(oldpathall).getChannel();
    outputChannel = new FileOutputStream(newpathall).getChannel();
    outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
} finally {
...
voidcopyFolders(File sourceFolder, File destFolder)
copy Folders
if (!destFolder.exists())
    destFolder.mkdirs();
File[] listFiles = sourceFolder.listFiles();
if (listFiles != null) {
    for (File srcFile : listFiles) {
        if (srcFile.isDirectory())
            copyFolders(srcFile, new File(destFolder, srcFile.getName()));
        if (srcFile.isFile()) {
...