private static void deleteDirectoryOnExit(File directory) throws IOException {
  if (!directory.exists()) {
    return;
  }
  directory.deleteOnExit();
  if (!isSymlink(directory)) {
    cleanDirectoryOnExit(directory);
  }
}

private static void deleteDirectoryOnExit ( File directory ) throws IOException { if ( ! directory . exists ( ) ) { return ; } directory . deleteOnExit ( ) ; if ( ! isSymlink ( directory ) ) { cleanDirectoryOnExit ( directory ) ; } }
schedules a directory recursively for deletion on jvm exit .
