Using Java nio to create a subdirectory and file

You could declare your confFile as File instead of Path. Then you can use confFile.getParentFile().mkdirs();, see example below:

// ...

File confFile = new File("./conf/conf.xml"); 
confFile.getParentFile().mkdirs();

// ...

Or, using your code as is, you can use:

Files.createDirectories(confFile.getParent());

Leave a Comment