public static void prune ( File file , File root ) { while ( ! file . equals ( root ) && file . delete ( ) ) { file = file . getParentFile ( ) ; } }
Removes a file or directory and its ancestors up to but not including the specified directory until a non - empty directory is reached .