URI (@NotNull Path file) { String path = file.toString().replace(File.separatorChar, '/'); if (!path.startsWith("/")) { path = '/' + path; } else if (path.startsWith("//")) { path = "//" + path; } try { return new URI("file", null, path, null); } catch (URISyntaxException e) { throw new IllegalArgumentException(path, e); } }