Package com.helger.commons.io.resource
Class URLResource
java.lang.Object
com.helger.commons.io.resource.URLResource
- All Implemented Interfaces:
IHasInputStream,IHasInputStreamAndReader,IReadableResource,IResourceBase
Implementation of the
IReadableResource interface for URL objects.- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionURLResource(ISimpleURL aURL) URLResource(String sURL) URLResource(URI aURI) URLResource(URL aURL) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanexists()getAsURI()getAsURL()Get the input stream to read from the object.getInputStream(int nConnectTimeoutMS, int nReadTimeoutMS) getInputStream(int nConnectTimeoutMS, int nReadTimeoutMS, IMutableWrapper<IOException> aExceptionHolder) getInputStream(int nConnectTimeoutMS, int nReadTimeoutMS, Consumer<? super URLConnection> aConnectionModifier, IMutableWrapper<IOException> aExceptionHolder) getInputStream(IMutableWrapper<IOException> aExceptionHolder) static InputStreamgetInputStream(URL aURL) getPath()getReadableCloneForPath(String sPath) Get a new resource of the same implementation type as this object but for a different path.getReadableCloneForPath(URL aURL) inthashCode()static booleanisExplicitURLResource(String sName) Check if the passed resource name is an explicit URL resource.final booleanCheck if theInputStreamfromIHasInputStream.getInputStream()andIHasInputStream.getBufferedInputStream()can be acquired more than once.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.io.IHasInputStream
getBufferedInputStreamMethods inherited from interface com.helger.commons.io.IHasInputStreamAndReader
getBufferedReader, getReader
-
Field Details
-
DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT- See Also:
-
DEFAULT_READ_TIMEOUT
public static final int DEFAULT_READ_TIMEOUT- See Also:
-
-
Constructor Details
-
URLResource
- Throws:
MalformedURLException
-
URLResource
- Throws:
MalformedURLException
-
URLResource
- Throws:
MalformedURLException
-
URLResource
-
-
Method Details
-
isExplicitURLResource
Check if the passed resource name is an explicit URL resource.- Parameters:
sName- The name to check. May benull.- Returns:
trueif the passed name is an explicit URL resource.
-
getResourceID
- Specified by:
getResourceIDin interfaceIResourceBase- Returns:
- A non-
nullresource ID used e.g. for system IDs in XML resolving.
-
getPath
- Specified by:
getPathin interfaceIResourceBase- Returns:
- The requested path. Never
null
-
getInputStream
-
getInputStream
Description copied from interface:IHasInputStreamGet the input stream to read from the object. Each time this method is called, a newInputStreamneeds to be created.- Specified by:
getInputStreamin interfaceIHasInputStream- Returns:
nullif resolving failed.
-
getInputStream
@Nullable public InputStream getInputStream(@CheckForSigned int nConnectTimeoutMS, @CheckForSigned int nReadTimeoutMS) -
getInputStream
@Nullable public InputStream getInputStream(@Nullable IMutableWrapper<IOException> aExceptionHolder) -
getInputStream
@Nullable public InputStream getInputStream(@CheckForSigned int nConnectTimeoutMS, @CheckForSigned int nReadTimeoutMS, @Nullable IMutableWrapper<IOException> aExceptionHolder) -
getInputStream
@Nullable public InputStream getInputStream(@CheckForSigned int nConnectTimeoutMS, @CheckForSigned int nReadTimeoutMS, @Nullable Consumer<? super URLConnection> aConnectionModifier, @Nullable IMutableWrapper<IOException> aExceptionHolder) -
isReadMultiple
public final boolean isReadMultiple()Description copied from interface:IHasInputStreamCheck if theInputStreamfromIHasInputStream.getInputStream()andIHasInputStream.getBufferedInputStream()can be acquired more than once.- Specified by:
isReadMultiplein interfaceIHasInputStream- Returns:
trueif the input stream can be acquired more than once,falseif not.
-
exists
public boolean exists()- Specified by:
existsin interfaceIResourceBase- Returns:
trueif the resource exists,falseotherwise.
-
getAsURL
- Specified by:
getAsURLin interfaceIResourceBase- Returns:
- the URL representation of this resource. May be
nullif this resource cannot be represented as an URL.
-
getAsURI
-
getAsFile
- Specified by:
getAsFilein interfaceIResourceBase- Returns:
- the File representation of this resource. May be
nullif this resource cannot be represented as a file.
-
getReadableCloneForPath
-
getReadableCloneForPath
Description copied from interface:IReadableResourceGet a new resource of the same implementation type as this object but for a different path.- Specified by:
getReadableCloneForPathin interfaceIReadableResource- Parameters:
sPath- The new path to use. May not benull.- Returns:
- The resource of the same implementation but a different path. May
not be
null.
-
equals
-
hashCode
public int hashCode() -
toString
-