Class URLUtil

java.lang.Object
com.intellij.openapi.util.URLUtil

public final class URLUtil extends Object
  • Field Details

  • Method Details

    • openStream

      @NotNull public static @NotNull InputStream openStream(@NotNull @NotNull URL url) throws IOException
      Opens a url stream. The semantics is the sames as URL.openStream(). The separate method is needed, since jar URLs open jars via JarFactory and thus keep them mapped into memory.
      Throws:
      IOException
    • splitJarUrl

      @Nullable public static @Nullable Pair<String,String> splitJarUrl(@NotNull @NotNull String url)
      Splits .jar URL along a separator and strips "jar" and "file" prefixes if any. Returns a pair of path to a .jar file and entry name inside a .jar, or null if the URL does not contain a separator.

      E.g. "jar:file:///path/to/jar.jar!/resource.xml" is converted into ["/path/to/jar.jar", "resource.xml"].

      Please note that the first part is platform-dependent - see UrlUtilTest.testJarUrlSplitter() for examples.

    • urlToFile

      @NotNull public static @NotNull File urlToFile(@NotNull @NotNull URL url)