public static File createTempDir(String prefix,boolean cleanup) throws IOException {
  Path tmpDir=Files.createTempDirectory(prefix);
  addCleanupHook(tmpDir);
  return tmpDir.toFile();
}

public static File createTempDir ( String prefix , boolean cleanup ) throws IOException { Path tmpDir = Files . createTempDirectory ( prefix ) ; addCleanupHook ( tmpDir ) ; return tmpDir . toFile ( ) ; }
create directory that is optionally cleaned up after the jvm shuts down through use of a runtime shutdown hook .
