com.fasterxml.aalto.util
Class URLUtil

java.lang.Object
  extended by com.fasterxml.aalto.util.URLUtil

public final class URLUtil
extends Object


Method Summary
static String fileToSystemId(File f)
           
static URL fileToURL(File f)
          This method is added because the default conversion using file.toURL() turns out to be rather slow, as it tries to figure out if the file is actually a directory.
static InputStream inputStreamFromURL(URL url)
          Method that tries to get a stream (ideally, optimal one) to read from the specified URL.
static OutputStream outputStreamFromURL(URL url)
          Method that tries to get a stream (ideally, optimal one) to write to the resource specified by given URL.
static URL urlFromCurrentDir()
          Method that tries to create and return URL that denotes current working directory.
static URL urlFromSystemId(String sysId)
          Method that tries to figure out how to create valid URL from a system id, without additional contextual information.
static URL urlFromSystemId(String sysId, URL ctxt)
           
static String urlToSystemId(URL u)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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. We could perhaps use java.net.URI class in future?

Throws:
IOException

urlFromSystemId

public static URL urlFromSystemId(String sysId,
                                  URL ctxt)
                           throws IOException
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

fileToURL

public static URL fileToURL(File f)
                     throws IOException
This method is added because the default conversion using file.toURL() turns out to be rather slow, as it tries to figure out if the file is actually a directory. Now, for our use cases this is irrelevant, so we can optimize out that expensive part.

Throws:
IOException

fileToSystemId

public static String fileToSystemId(File f)
                             throws IOException
Throws:
IOException

urlToSystemId

public static String urlToSystemId(URL u)


Copyright © 2012 Fasterxml.com. All Rights Reserved.