Package com.fasterxml.aalto.util
Class URLUtil
java.lang.Object
com.fasterxml.aalto.util.URLUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
static URL
This method is added because the default conversion usingfile.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.private static void
throwIoException
(MalformedURLException mex, String sysId) Helper method that tries to fully convert strange URL-specific exception to more general IO exception.static URL
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)
-
Constructor Details
-
URLUtil
private URLUtil()
-
-
Method Details
-
urlFromSystemId
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
- Throws:
IOException
-
urlFromCurrentDir
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
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
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
This method is added because the default conversion usingfile.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
- Throws:
IOException
-
urlToSystemId
-
throwIoException
Helper method that tries to fully convert strange URL-specific exception to more general IO exception. Also, to try to use JDK 1.4 feature without creating requirement, uses reflection to try to set the root cause, if we are running on JDK1.4- Throws:
IOException
-