Package com.ctc.wstx.util
Class URLUtil
- java.lang.Object
-
- com.ctc.wstx.util.URLUtil
-
public final class URLUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternURI_WINDOWS_FILE_PATTERNWhile URIs that contain pipe are wrong, we'll work around that for [WSTX-275].
-
Constructor Summary
Constructors Modifier Constructor Description privateURLUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.StringcleanSystemId(java.lang.String sysId)static java.io.InputStreaminputStreamFromURL(java.net.URL url)Method that tries to get a stream (ideally, optimal one) to read from the specified URL.static java.io.OutputStreamoutputStreamFromURL(java.net.URL url)Method that tries to get a stream (ideally, optimal one) to write to the resource specified by given URL.private static voidthrowIOException(java.lang.Exception mex, java.lang.String sysId)Helper method that tries to fully convert strange URL-specific exception to more general IO exception.static java.net.URLtoURL(java.io.File f)Helper method that will convert given file into equivalent URL.static java.net.URIuriFromSystemId(java.lang.String sysId)static java.net.URLurlFromCurrentDir()Method that tries to create and return URL that denotes current working directory.static java.net.URLurlFromSystemId(java.lang.String sysId)Method that tries to figure out how to create valid URL from a system id, without additional contextual information.static java.net.URLurlFromSystemId(java.lang.String sysId, java.net.URL ctxt)
-
-
-
Method Detail
-
urlFromSystemId
public static java.net.URL urlFromSystemId(java.lang.String sysId) throws java.io.IOExceptionMethod 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:
java.io.IOException
-
uriFromSystemId
public static java.net.URI uriFromSystemId(java.lang.String sysId) throws java.io.IOException- Throws:
java.io.IOException- Since:
- 4.1
-
urlFromSystemId
public static java.net.URL urlFromSystemId(java.lang.String sysId, java.net.URL ctxt) throws java.io.IOException- Throws:
java.io.IOException
-
urlFromCurrentDir
public static java.net.URL urlFromCurrentDir() throws java.io.IOExceptionMethod 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:
java.io.IOException
-
inputStreamFromURL
public static java.io.InputStream inputStreamFromURL(java.net.URL url) throws java.io.IOExceptionMethod 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:
java.io.IOException
-
outputStreamFromURL
public static java.io.OutputStream outputStreamFromURL(java.net.URL url) throws java.io.IOExceptionMethod 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:
java.io.IOException
-
toURL
public static java.net.URL toURL(java.io.File f) throws java.io.IOExceptionHelper method that will convert given file into equivalent URL. Encapsulated as a separate method to allow for working around problems with deprecation ofFile.toURL()method.- Throws:
java.io.IOException
-
cleanSystemId
private static java.lang.String cleanSystemId(java.lang.String sysId)
-
throwIOException
private static void throwIOException(java.lang.Exception mex, java.lang.String sysId) throws java.io.IOExceptionHelper 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:
java.io.IOException
-
-