public static void forceDeleteOnExit(File file) throws IOException {
  if (file.isDirectory()) {
    deleteDirectoryOnExit(file);
  }
 else {
    file.deleteOnExit();
  }
}

public static void forceDeleteOnExit ( File file ) throws IOException { if ( file . isDirectory ( ) ) { deleteDirectoryOnExit ( file ) ; } else { file . deleteOnExit ( ) ; } }
schedules a file to be deleted when jvm exits . if file is directory delete it and all sub - directories .
