@NotNull public static String convertFromUrl(@NotNull URL url) { String protocol = url.getProtocol(); String path = url.getPath(); if (protocol.equals(JAR)) { if (StringUtil.startsWithConcatenationOf(path, FILE, PROTOCOL_DELIMITER)) { try { URL subURL = new URL(path); path = subURL.getPath(); } catch (MalformedURLException e) { throw new RuntimeException(VfsBundle.message("url.parse.unhandled.exception"), e); } } else { throw new RuntimeException( new IOException(VfsBundle.message("url.parse.error", url.toExternalForm()))); } } if (SystemInfo.isWindows || SystemInfo.isOS2) { while (path.length() > 0 && path.charAt(0) == '/') { path = path.substring(1, path.length()); } } path = URLUtil.unescapePercentSequences(path); return protocol + "://" + path; }
@NotNull public static String unquote(@NotNull String urlString) { urlString = urlString.replace('/', File.separatorChar); return URLUtil.unescapePercentSequences(urlString); }