Starting with Java 7 , you can use java.nio.file.Files and java.nio.file.Paths .
Path path = Paths.get("C:\\Images\\Background\\..\\Foreground\\Necklace\\..\\Earrings\\..\\Etc"); try { Files.createDirectories(path); } catch (IOException e) { System.err.println("Cannot create directories - " + e); }
This is a difficult decision (because I used only one way to go to the whole structure).
If you don't like complex solutions, you can use 4 simple ways:
Path p1 = Paths.get("C:\\Images\\Background"); Path p2 = Paths.get("C:\\Images\\Foreground\\Necklace"); Path p3 = Paths.get("C:\\Images\\Foreground\\Earrings"); Path p4 = Paths.get("C:\\Images\\Foreground\\Etc");
and then call the createDirectories method for all of them:
Files.createDirectories(p1); Files.createDirectories(p2); Files.createDirectories(p3); Files.createDirectories(p4);
ROMANIA_engineer
source share