Create Directory with java.nio.file.Files in Java
Description
The following code shows how to create Directory with java.nio.file.Files.
Example
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
//from w ww. ja v a 2 s . c om
public class Main {
public static void main(String[] args) throws Exception {
Path newPath = FileSystems.getDefault().getPath("C:\\home\\docs\\");
Path myDirectory = Files.createDirectory(newPath);
System.out.println("Directory created successfully!");
}
}
The code above generates the following result.