java.lang.Object
io.smallrye.common.resource.Resource
io.smallrye.common.resource.PathResource
A resource corresponding to a
Path.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasBuffer()Returns the bytes of this resource, as a read-only byte buffer.Returns the resource content as a string.booleanReturns true if this resource represents a directory, or false otherwise.Returns the modification time of the resource, ornullif the time is unknown.Open a directory stream to read the contents of this directory.Open an input stream to read this resource.path()Returns the path of this resource.longsize()Returns the size of the resource, or-1if the size is not known.url()Returns the resource URL (notnull).Methods inherited from class io.smallrye.common.resource.Resource
codeSigners, copyTo, copyTo, copyTo, pathName, readStream
-
Constructor Details
-
PathResource
Construct a new instance.- Parameters:
pathName- the relative path name (must not benull)path- the path (must not benull)
-
-
Method Details
-
path
Returns the path of this resource.- Returns:
- the path of this resource
-
url
Description copied from class:ResourceReturns the resource URL (notnull). If the resource location information cannot be converted to a URL, an exception may be thrown. -
openDirectoryStream
Description copied from class:ResourceOpen a directory stream to read the contents of this directory. Not every resource implementation supports directory access.- Overrides:
openDirectoryStreamin classResource- Returns:
- the directory stream (not
null) - Throws:
IOException- if the directory could not be opened or the resource is not a directory
-
isDirectory
public boolean isDirectory()Description copied from class:ResourceReturns true if this resource represents a directory, or false otherwise. Not every resource implementation supports directory access.- Overrides:
isDirectoryin classResource- Returns:
- true if this resource represents a directory, or false otherwise
-
openStream
Description copied from class:ResourceOpen an input stream to read this resource.- Specified by:
openStreamin classResource- Returns:
- the input stream (not
null) - Throws:
IOException- if the input stream could not be opened or the resource is a directory
-
asBuffer
Description copied from class:ResourceReturns the bytes of this resource, as a read-only byte buffer. The buffer is suitable for passing toClassLoader.defineClass(String, ByteBuffer, ProtectionDomain). The default implementation reads all of the resource bytes from the stream returned byResource.openStream(). Other implementations might return a buffer for data already contained in memory, or might return a memory-mapped buffer if the resource is very large. The buffer might or might not be cached on the resource. Because of this, care should be taken to avoid calling this method repeatedly for a single resource.- Overrides:
asBufferin classResource- Returns:
- the bytes of this resource, as a read-only byte buffer
- Throws:
IOException- if the content could not be read
-
asString
Description copied from class:ResourceReturns the resource content as a string.- Overrides:
asStringin classResource- Parameters:
charset- the character set to use for decoding (must not benull)- Returns:
- the resource content as a string
- Throws:
IOException- if the content could not be read
-
modifiedTime
Description copied from class:ResourceReturns the modification time of the resource, ornullif the time is unknown.- Overrides:
modifiedTimein classResource- Returns:
- the modification time of the resource, or
nullif the time is unknown
-
size
public long size()Description copied from class:ResourceReturns the size of the resource, or-1if the size is not known.
-