Package org.eclipse.jetty.util.resource
Class MemoryResource
java.lang.Object
org.eclipse.jetty.util.resource.Resource
org.eclipse.jetty.util.resource.MemoryResource
An in memory Resource created from a URL
-
Method Summary
Modifier and TypeMethodDescriptionboolean
exists()
Equivalent toFiles.exists(Path, LinkOption...)
with the following parameters:Resource.getPath()
andLinkOption.NOFOLLOW_LINKS
.Get a deep collection of contained resources.byte[]
getBytes()
The file name of the resource.getName()
The full name of the resource.getPath()
Return the Path corresponding to this resource.getURI()
URI representing the resource.boolean
isContainedIn
(Resource container) Return true if this resource is contained in the Resource r, either because r is a folder or a jar file or any form of resource capable of containing other resources.boolean
Return true if resource represents a directory of potential resources.boolean
True if the resource is readable.The time the resource was last modified.long
length()
Length of the resource.list()
List of contents of a directoryResource
.Creates a new input stream to the resource.Readable ByteChannel for the resource.Resolve an existing Resource.toString()
Methods inherited from class org.eclipse.jetty.util.resource.Resource
contains, copyTo, dump, getPathTo, getRealURI, isAlias, isSameFile, iterator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
getBytes
public byte[] getBytes() -
getPath
Description copied from class:Resource
Return the Path corresponding to this resource. -
isDirectory
public boolean isDirectory()Description copied from class:Resource
Return true if resource represents a directory of potential resources.- Specified by:
isDirectory
in classResource
- Returns:
- true if the represented resource is a container/directory.
-
isReadable
public boolean isReadable()Description copied from class:Resource
True if the resource is readable.- Specified by:
isReadable
in classResource
- Returns:
- true if the represented resource exists, and can read from.
-
isContainedIn
Description copied from class:Resource
Return true if this resource is contained in the Resource r, either because r is a folder or a jar file or any form of resource capable of containing other resources.- Overrides:
isContainedIn
in classResource
- Parameters:
container
- the containing resource- Returns:
- true if this Resource is contained, false otherwise
- See Also:
-
getURI
Description copied from class:Resource
URI representing the resource. -
getName
Description copied from class:Resource
The full name of the resource. -
getFileName
Description copied from class:Resource
The file name of the resource.
This is the last segment of the path.
- Specified by:
getFileName
in classResource
- Returns:
- the filename of the resource, or "" if there are no path segments (eg: path of "/"), or null if resource cannot determine a filename.
- See Also:
-
lastModified
Description copied from class:Resource
The time the resource was last modified.- Overrides:
lastModified
in classResource
- Returns:
- the last modified time instant, or
Instant.EPOCH
if unable to obtain last modified.
-
length
public long length()Description copied from class:Resource
Length of the resource. -
resolve
Description copied from class:Resource
Resolve an existing Resource. -
newInputStream
Description copied from class:Resource
Creates a new input stream to the resource.- Overrides:
newInputStream
in classResource
- Returns:
- an input stream to the resource or null if one is not available.
- Throws:
IOException
- if there is a problem opening the input stream
-
newReadableByteChannel
Description copied from class:Resource
Readable ByteChannel for the resource.- Overrides:
newReadableByteChannel
in classResource
- Returns:
- a readable
ByteChannel
to the resource or null if one is not available. - Throws:
IOException
- if unable to open the readable bytechannel for the resource.
-
exists
public boolean exists()Description copied from class:Resource
Equivalent toFiles.exists(Path, LinkOption...)
with the following parameters:Resource.getPath()
andLinkOption.NOFOLLOW_LINKS
. -
list
Description copied from class:Resource
List of contents of a directory
Resource
.Ordering is
FileSystem
dependent, so callers may wish to sort the return value to ensure deterministic behavior. -
getAllResources
Description copied from class:Resource
Get a deep collection of contained resources.- Overrides:
getAllResources
in classResource
- Returns:
- A collection of all Resources deeply contained within this resource if it is a directory, otherwise an empty collection is returned.
-
toString
-