public interface Resource extends HasName
Modifier and Type | Method and Description |
---|---|
OutputStream |
append()
Opens up an
OutputStream to append to the resource. |
void |
append(Action<OutputStream> appendCallback)
Opens up an
InputStream to append (write at the end of the
existing stream) to the resource. |
long |
getLastModified()
Gets the last modified timestamp value (measured in milliseconds since
the epoch (00:00:00 GMT, January 1, 1970)) of the resource, if available.
|
String |
getName()
Gets the name of the resource, typically a filename or other identifying
string
|
String |
getQualifiedPath()
Gets the qualified path of the resource, which typically includes slash
or backslash separated nodes in a hierarical tree structure.
|
long |
getSize()
Gets the size (in number of bytes) of this resource's data.
|
boolean |
isExists()
Determines if the resource referenced by this object exists or not.
|
boolean |
isReadOnly()
Determines if the file is read only, or if writes are also possible.
|
InputStream |
read()
Opens up an
InputStream to read from the resource. |
void |
read(Action<InputStream> readCallback)
Opens up an
InputStream to read from the resource, and allows a
callback to perform writing actions on it. |
<E> E |
read(Function<InputStream,E> readCallback)
* Opens up an
InputStream to read from the resource, and allows a
callback function to perform writing actions on it and return the
function's result. |
<E> E |
read(UncheckedFunc<InputStream,E> readCallback)
Opens up an
InputStream to read from the resource, and allows a
callback function to perform writing actions on it and return the
function's result. |
OutputStream |
write()
Opens up an
OutputStream to write to the resource. |
void |
write(Action<OutputStream> writeCallback)
Opens up an
OutputStream to write to the resource, and allows a
callback to perform writing actions on it. |
String getName()
String getQualifiedPath()
boolean isReadOnly()
boolean isExists()
long getSize()
long getLastModified()
void write(Action<OutputStream> writeCallback) throws ResourceException
OutputStream
to write to the resource, and allows a
callback to perform writing actions on it.writeCallback
- a callback which should define what to write to the resource.ResourceException
- if an error occurs while writingOutputStream write() throws ResourceException
OutputStream
to write to the resource. Consumers of
this method are expected to invoke the OutputStream.close()
method manually.
If possible, the other write(...) method is preferred over this one,
since it guarantees proper closing of the resource's handles.ResourceException
void append(Action<OutputStream> appendCallback) throws ResourceException
InputStream
to append (write at the end of the
existing stream) to the resource.appendCallback
- a callback which should define what to append to the resource.ResourceException
- if an error occurs while appendingOutputStream append() throws ResourceException
OutputStream
to append to the resource. Consumers of
this method are expected to invoke the OutputStream.close()
method manually.
If possible, the other append(...) method is preferred over this one,
since it guarantees proper closing of the resource's handles.ResourceException
InputStream read() throws ResourceException
InputStream
to read from the resource. Consumers of
this method are expected to invoke the InputStream.close()
method
manually.
If possible, the other read(...) methods are preferred over this one,
since they guarantee proper closing of the resource's handles.ResourceException
void read(Action<InputStream> readCallback) throws ResourceException
InputStream
to read from the resource, and allows a
callback to perform writing actions on it.readCallback
- ResourceException
- if an error occurs while reading<E> E read(UncheckedFunc<InputStream,E> readCallback) throws ResourceException
InputStream
to read from the resource, and allows a
callback function to perform writing actions on it and return the
function's result.readCallback
- ResourceException
- if an error occurs while reading<E> E read(Function<InputStream,E> readCallback) throws ResourceException
InputStream
to read from the resource, and allows a
callback function to perform writing actions on it and return the
function's result.readCallback
- ResourceException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.