使用下面的範例, 建立目錄:
Path path = Paths.get("/tmp/your-folder/");
if (!Files.exists(path)) {
Path directories;
try {
directories = Files.createDirectories(path);
System.out.println("directories created: " + directories);
System.out.println("dir created exits: " + Files.exists(directories));
} catch (IOException e) {
e.printStackTrace();
}
}