To create a new directory, call
All but the last component in the path must already exist. To create intermediate directories as well, use
You can create an empty file with
The call throws an exception if the file already exists. The check for existence and creation are atomic. If the file doesn’t exist, it is created before anyone else has a chance to do the same.
There are convenience methods for creating a temporary file or directory in a given or system-specific location.
Path newPath = Files.createTempFile(dir, prefix, suffix); Path newPath = Files.createTempFile(prefix, suffix); Path newPath ...