Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(uri); if (matcher.matches()) { return withScheme("file").withPath(matcher.group(2)).withoutHostname().withoutHostnamePort(); withScheme(matcher.group(1)); if (!"file".equals(matcher.group(1)) && matcher.group(4) != null) { withPath(matcher.group(7)); return withScheme("ssh").withPath(matcher.group(4)).withHostnamePort(matcher.group(3),22); return withScheme("ssh").withPath(matcher.group(4)).withHostnamePort(matcher.group(3),22); return withScheme("file").withPath(matcher.group(2)).withoutHostname().withoutHostnamePort();