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)); if (matcher.group(5) != null) { withHostnamePort(matcher.group(4), Integer.parseInt(matcher.group(5))); withPath(matcher.group(4)+"/"+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();