public class FileResource extends AbstractResource implements Serializable
Constructor and Description |
---|
FileResource(File file) |
FileResource(String filename) |
Modifier and Type | Method and Description |
---|---|
OutputStream |
append()
Opens up an
OutputStream to append to the resource. |
File |
getFile() |
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. |
String |
toString() |
OutputStream |
write()
Opens up an
OutputStream to write to the resource. |
public FileResource(String filename)
public FileResource(File file)
public String toString()
toString
in class AbstractResource
public String getName()
Resource
public String getQualifiedPath()
Resource
getQualifiedPath
in interface Resource
public boolean isReadOnly()
Resource
isReadOnly
in interface Resource
public OutputStream write() throws ResourceException
Resource
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.write
in interface Resource
ResourceException
public OutputStream append() throws ResourceException
Resource
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.append
in interface Resource
ResourceException
public File getFile()
public boolean isExists()
Resource
public long getSize()
Resource
public long getLastModified()
Resource
getLastModified
in interface Resource
public InputStream read() throws ResourceException
Resource
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.read
in interface Resource
ResourceException
Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.