Top Description Fields Constructors Methods
io.smallrye.common.resource

public final Class URLResource

extends Resource
Class Inheritance
Imports
java.io.IOException, .InputStream, java.net.JarURLConnection, .URL, .URLConnection, java.time.Instant, java.util.Objects, io.smallrye.common.constraint.Assert

A resource backed by a connection to a URL.

Field Summary

Modifier and TypeField and Description
private final URLConnection

Constructor Summary

AccessConstructor and Description
public
URLResource(final String
the resource path name (must not be null)
pathName
,
final URL
the URL (must not be null)
url
)

Construct a new instance for a URL.

public
URLResource(final String
the resource path name (must not be null)
pathName
,
final URLConnection
the URL connection (must not be null)
connection
)

Construct a new instance.

public
URLResource(final JarURLConnection
the JAR URL connection (must not be null)
jarConnection
)

Construct a new instance for a JAR URL connection.

Method Summary

Modifier and TypeMethod and Description
public Instant
modifiedTime()

Overrides io.smallrye.common.resource.Resource.modifiedTime.

Returns the modification time of the resource, or null if the time is unknown.

public InputStream
openStream()

Implements abstract io.smallrye.common.resource.Resource.openStream.

Open an input stream to read this resource.

public long
size()

Implements abstract io.smallrye.common.resource.Resource.size.

Returns the size of the resource, or -1 if the size is not known.

public URL
url()

Implements abstract io.smallrye.common.resource.Resource.url.

Returns the resource URL (not null).

Inherited from io.smallrye.common.resource.Resource:
asBufferasStringcodeSignerscopyTocopyTocopyToisDirectoryopenDirectoryStreampathNamereadStream

Field Detail

connectionback to summary
private final URLConnection connection

Constructor Detail

URLResourceback to summary
public URLResource(final String pathName, final URL url) throws IOException

Construct a new instance for a URL.

Parameters
pathName:String

the resource path name (must not be null)

url:URL

the URL (must not be null)

Exceptions
IOException:
if the connection could not be opened
URLResourceback to summary
public URLResource(final String pathName, final URLConnection connection)

Construct a new instance.

Parameters
pathName:String

the resource path name (must not be null)

connection:URLConnection

the URL connection (must not be null)

URLResourceback to summary
public URLResource(final JarURLConnection jarConnection)

Construct a new instance for a JAR URL connection. The JAR entry name is used as the resource name.

Parameters
jarConnection:JarURLConnection

the JAR URL connection (must not be null)

Method Detail

modifiedTimeback to summary
public Instant modifiedTime()

Overrides io.smallrye.common.resource.Resource.modifiedTime.

Doc from io.smallrye.common.resource.Resource.modifiedTime.

Returns the modification time of the resource, or null if the time is unknown.

Returns:Instant

the modification time of the resource, or null if the time is unknown

openStreamback to summary
public InputStream openStream() throws IOException

Implements abstract io.smallrye.common.resource.Resource.openStream.

Doc from io.smallrye.common.resource.Resource.openStream.

Open an input stream to read this resource.

Returns:InputStream

the input stream (not null)

Exceptions
IOException:
if the input stream could not be opened or the resource is a directory
sizeback to summary
public long size()

Implements abstract io.smallrye.common.resource.Resource.size.

Doc from io.smallrye.common.resource.Resource.size.

Returns the size of the resource, or -1 if the size is not known.

Returns:long

the size of the resource, or -1 if the size is not known

urlback to summary
public URL url()

Implements abstract io.smallrye.common.resource.Resource.url.

Doc from io.smallrye.common.resource.Resource.url.

Returns the resource URL (not null). If the resource location information cannot be converted to a URL, an exception may be thrown.

Returns:URL

the resource URL (not null)