int (@NotNull String path, @NotNull Appendable result) { try { if (SystemInfoRt.isWindows && path.length() > 1 && path.charAt(0) == '/' && path.charAt(1) == '/') { result.append("//"); int hostStart = 2; while (hostStart < path.length() && path.charAt(hostStart) == '/') hostStart++; if (hostStart == path.length()) return hostStart; int hostEnd = path.indexOf('/', hostStart); if (hostEnd < 0) hostEnd = path.length(); result.append(path, hostStart, hostEnd); result.append('/'); int shareStart = hostEnd; while (shareStart < path.length() && path.charAt(shareStart) == '/') shareStart++; if (shareStart == path.length()) return shareStart; int shareEnd = path.indexOf('/', shareStart); if (shareEnd < 0) shareEnd = path.length(); result.append(path, shareStart, shareEnd); result.append('/'); return shareEnd; } if (!path.isEmpty() && path.charAt(0) == '/') { result.append('/'); return 1; } if (path.length() > 2 && path.charAt(1) == ':' && path.charAt(2) == '/') { result.append(path, 0, 3); return 3; } return 0; } catch (IOException e) { throw new RuntimeException(e); } }