Class URLUtil


  • public final class URLUtil
    extends Object
    • Method Detail

      • urlFromSystemId

        public static URL urlFromSystemId​(String sysId)
                                   throws IOException
        Method that tries to figure out how to create valid URL from a system id, without additional contextual information. If we could use URIs this might be easier to do, but they are part of JDK 1.4, and preferably code should only require 1.2 (or maybe 1.3)
        Throws:
        IOException
      • urlFromCurrentDir

        public static URL urlFromCurrentDir()
                                     throws IOException
        Method that tries to create and return URL that denotes current working directory. Usually used to create a context, when one is not explicitly passed.
        Throws:
        IOException
      • inputStreamFromURL

        public static InputStream inputStreamFromURL​(URL url)
                                              throws IOException
        Method that tries to get a stream (ideally, optimal one) to read from the specified URL. Currently it just means creating a simple file input stream if the URL points to a (local) file, and otherwise relying on URL classes input stream creation method.
        Throws:
        IOException
      • outputStreamFromURL

        public static OutputStream outputStreamFromURL​(URL url)
                                                throws IOException
        Method that tries to get a stream (ideally, optimal one) to write to the resource specified by given URL. Currently it just means creating a simple file output stream if the URL points to a (local) file, and otherwise relying on URL classes input stream creation method.
        Throws:
        IOException
      • toURL

        public static URL toURL​(File f)
                         throws IOException
        Helper method that will convert given file into equivalent URL. Encapsulated as a separate method to allow for working around problems with deprecation of File.toURL() method.
        Throws:
        IOException