public static Path createDirectory(final Path parent,final String folderName){
  final File file=new File(parent.toFile(),folderName);
  if (!file.exists()) {
    if (!file.mkdir()) {
      throw new RuntimeException("Error while trying to create folder at " + parent + " with "+ folderName+ ".");
    }
  }
  file.deleteOnExit();
  return file.toPath();
}

public static Path createDirectory ( final Path parent , final String folderName ) { final File file = new File ( parent . toFile ( ) , folderName ) ; if ( ! file . exists ( ) ) { if ( ! file . mkdir ( ) ) { throw new RuntimeException ( "Error while trying to create folder at " + parent + " with " + folderName + "." ) ; } } file . deleteOnExit ( ) ; return file . toPath ( ) ; }
creates a new directory with the given parent folder and folder name . the newly created folder will be deleted on graceful vm shutdown .
