public static void flatten(File dirToRemove) throws IOException {
  final File parent=dirToRemove.getParentFile();
  for (  File child : FileMisc.list(dirToRemove)) {
    boolean createDestDir=false;
    if (child.isFile()) {
      FileUtils.moveFileToDirectory(child,parent,createDestDir);
    }
 else     if (child.isDirectory()) {
      FileUtils.moveDirectoryToDirectory(child,parent,createDestDir);
    }
 else {
      throw new IllegalArgumentException("Unknown filetype: " + child);
    }
  }
  FileMisc.forceDelete(dirToRemove);
}

public static void flatten ( File dirToRemove ) throws IOException { final File parent = dirToRemove . getParentFile ( ) ; for ( File child : FileMisc . list ( dirToRemove ) ) { boolean createDestDir = false ; if ( child . isFile ( ) ) { FileUtils . moveFileToDirectory ( child , parent , createDestDir ) ; } else if ( child . isDirectory ( ) ) { FileUtils . moveDirectoryToDirectory ( child , parent , createDestDir ) ; } else { throw new IllegalArgumentException ( "Unknown filetype: " + child ) ; } } FileMisc . forceDelete ( dirToRemove ) ; }
flattens a single directory ( moves its children to be its peers , then deletes the given directory . ` ` ` before : root / toflatten / child1 child2 flatten ( " root / toflatten " ) after : root / child1 child2 ` ` `
