Top Fields Constructors Methods
com.ctc.wstx.util

public final Class URLUtil

extends Object
Class Inheritance
Imports
java.io.*, java.net.*, java.util.regex.Pattern

Field Summary

Modifier and TypeField and Description
private static final Pattern
URI_WINDOWS_FILE_PATTERN

While URIs that contain pipe are wrong, we'll work around that for [WSTX-275].

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static String
cleanSystemId(final String sysId)

public static InputStream
inputStreamFromURL(URL url)

Method that tries to get a stream (ideally, optimal one) to read from the specified URL.

public 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(Exception mex, String sysId)

Helper method that tries to fully convert strange URL-specific exception to more general IO exception.

public static URL
toURL(File f)

Helper method that will convert given file into equivalent URL.

public static URI
uriFromSystemId(final String sysId)

public static URL
urlFromCurrentDir()

Method that tries to create and return URL that denotes current working directory.

public static URL
urlFromSystemId(String sysId)

Method that tries to figure out how to create valid URL from a system id, without additional contextual information.

public static URL
urlFromSystemId(String sysId, URL ctxt)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

URI_WINDOWS_FILE_PATTERNback to summary
private static final Pattern URI_WINDOWS_FILE_PATTERN

While URIs that contain pipe are wrong, we'll work around that for [WSTX-275].

Constructor Detail

URLUtilback to summary
private URLUtil()

Method Detail

cleanSystemIdback to summary
private static String cleanSystemId(final String sysId)
inputStreamFromURLback to summary
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.

outputStreamFromURLback to summary
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.

throwIOExceptionback to summary
private static void throwIOException(Exception mex, String sysId) throws IOException

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

toURLback to summary
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.

uriFromSystemIdback to summary
public static URI uriFromSystemId(final String sysId) throws IOException
Since
4.1
urlFromCurrentDirback to summary
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.

urlFromSystemIdback to summary
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)

urlFromSystemIdback to summary
public static URL urlFromSystemId(String sysId, URL ctxt) throws IOException