@Test public void creates_parent_dirs_if_necessary() throws IOException { Path parentDir = baseDir.resolve("does/not/exist"); UniqueDirectories.createUniqueDir(parentDir, 123); assertThat("creates the parent dir", parentDir, satisfies(p -> Files.isDirectory(p))); }
public static Path createUniqueDir(Path parentDir, long sequence) throws IOException { Files.createDirectories(parentDir); while (true) { Path path = parentDir.resolve(Long.toString(sequence)); try { return Files.createDirectory(path); } catch (FileAlreadyExistsException e) { sequence++; } } }
UniqueDirectories { public static Path createUniqueDir(Path parentDir, long sequence) throws IOException { Files.createDirectories(parentDir); while (true) { Path path = parentDir.resolve(Long.toString(sequence)); try { return Files.createDirectory(path); } catch (FileAlreadyExistsException e) { sequence++; } } } }
UniqueDirectories { public static Path createUniqueDir(Path parentDir, long sequence) throws IOException { Files.createDirectories(parentDir); while (true) { Path path = parentDir.resolve(Long.toString(sequence)); try { return Files.createDirectory(path); } catch (FileAlreadyExistsException e) { sequence++; } } }  }
UniqueDirectories { public static Path createUniqueDir(Path parentDir, long sequence) throws IOException { Files.createDirectories(parentDir); while (true) { Path path = parentDir.resolve(Long.toString(sequence)); try { return Files.createDirectory(path); } catch (FileAlreadyExistsException e) { sequence++; } } }  static Path createUniqueDir(Path parentDir, long sequence); }
UniqueDirectories { public static Path createUniqueDir(Path parentDir, long sequence) throws IOException { Files.createDirectories(parentDir); while (true) { Path path = parentDir.resolve(Long.toString(sequence)); try { return Files.createDirectory(path); } catch (FileAlreadyExistsException e) { sequence++; } } }  static Path createUniqueDir(Path parentDir, long sequence);  }