java.nio.file.Files provides two method to create directory. The createDirectories method should be used where it is required to create all nonexistent parent directories first. The createDirectory method creates directory and throws exception when parent directory does not exist.
Here is example how to use Files class to create directories.
public class FilesExample2 { public void example() throws IOException { Path folder = Paths.get("d:/temp", "temp1", "temp2"); Files.createDirectories(folder); System.out.println(folder.toAbsolutePath()); Path child = Paths.get(folder.toAbsolutePath().toString(), "child"); Files.createDirectory(child); System.out.println(child.toAbsolutePath()); } public static void main(String []args) throws IOException{ FilesExample2 obj = new FilesExample2(); obj.example(); } }