char () { Set<Character> roots = StreamSupport.stream(FileSystems.getDefault().getRootDirectories().spliterator(), false) .map(root -> StringUtil.toUpperCase(root.toString()).charAt(0)) .collect(Collectors.toSet()); Logger.getInstance(IoTestUtil.class).debug("logical drives: " + roots); for (char c = 'E'; c <= 'Z'; c++) { if (!roots.contains(c)) { return c; } } throw new RuntimeException("No free roots"); }