[Solved] Java – Moving all sub-directory files to Parent Directory


   private static void move(File toDir, File currDir) {
        for (File file : currDir.listFiles()) {
            if (file.isDirectory()) {
                move(toDir, file);
            } else {
                file.renameTo(new File(toDir, file.getName()));
            }
        }
    }

Usage: pass it parent directory (ex. move(parentDir, parentDir)).

1

solved Java – Moving all sub-directory files to Parent Directory