I\'m creating a simple program that will try to read in \"conf/conf.xml\" from disk, but if this file or dir doesn\'t exist will instead create them.
I can do this u
You could do the following:
// Get your Path from the string
Path confFile = Paths.get("./conf/conf.xml");
// Get the portion of path that represtents directory structure.
Path subpath = confFile.subpath(0, confFile.getNameCount() - 1);
// Create all directories recursively
/**
* Creates a directory by creating all nonexistent parent directories first.
* Unlike the {@link #createDirectory createDirectory} method, an exception
* is not thrown if the directory could not be created because it already
* exists.
*
*/
Files.createDirectories(subpath.toAbsolutePath()))