public interface FileContent
To read from a file, use the InputStream
returned by
getInputStream()
.
To write to a file, use the OutputStream
returned by
getOutputStream()
method. This will create the file, and the parent
folder, if necessary.
A file may have multiple InputStreams open at the sametime.
FileObject.getContent()
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all resources used by the content, including any open stream.
|
Object |
getAttribute(String attrName)
Gets the value of an attribute of the file's content.
|
String[] |
getAttributeNames()
Lists the attributes of the file's content.
|
Map<String,Object> |
getAttributes()
Returns a read-only map of this file's attributes.
|
Certificate[] |
getCertificates()
Retrieves the certificates if any used to sign this file or folder.
|
FileContentInfo |
getContentInfo()
get the content info.
|
FileObject |
getFile()
Returns the file which this is the content of.
|
InputStream |
getInputStream()
Returns an input stream for reading the file's content.
|
long |
getLastModifiedTime()
Determines the last-modified timestamp of the file.
|
OutputStream |
getOutputStream()
Returns an output stream for writing the file's content.
|
OutputStream |
getOutputStream(boolean bAppend)
Returns an output stream for writing the file's content.
|
RandomAccessContent |
getRandomAccessContent(RandomAccessMode mode)
Returns an stream for reading/writing the file's content.
|
long |
getSize()
Determines the size of the file, in bytes.
|
boolean |
hasAttribute(String attrName)
Checks if an attribute of the file's content exists.
|
boolean |
isOpen()
check if this file has open streams.
|
void |
removeAttribute(String attrName)
Removes the value of an attribute of the file's content.
|
void |
setAttribute(String attrName,
Object value)
Sets the value of an attribute of the file's content.
|
void |
setLastModifiedTime(long modTime)
Sets the last-modified timestamp of the file.
|
FileObject getFile()
long getSize() throws FileSystemException
FileSystemException
- If the file does not exist, or is being written to, or on error
determining the size.long getLastModifiedTime() throws FileSystemException
FileSystemException
- If the file does not exist, or is being written to, or on error
determining the last-modified timestamp.void setLastModifiedTime(long modTime) throws FileSystemException
modTime
- The time to set the last-modified timestamp to.FileSystemException
- If the file is read-only, or is being written to, or on error
setting the last-modified timestamp.boolean hasAttribute(String attrName) throws FileSystemException
attrName
- The name of the attribute.FileSystemException
- If the file does not exist, or does not support
attributes.Map<String,Object> getAttributes() throws FileSystemException
FileSystemException
- If the file does not exist, or does not support attributes.String[] getAttributeNames() throws FileSystemException
FileSystemException
- If the file does not exist, or does not support attributes.Object getAttribute(String attrName) throws FileSystemException
attrName
- The name of the attribute. Attribute names are case insensitive.FileSystemException
- If the file does not exist, or does not support attributes.void setAttribute(String attrName, Object value) throws FileSystemException
attrName
- The name of the attribute.value
- The value of the attribute.FileSystemException
- If the file does not exist, or is read-only, or does not support
attributes, or on error setting the attribute.void removeAttribute(String attrName) throws FileSystemException
attrName
- The name of the attribute.FileSystemException
- If the file does not exist, or is read-only, or does not support
attributes, or on error removing the attribute.Certificate[] getCertificates() throws FileSystemException
FileSystemException
- If the file does not exist, or is being written.InputStream getInputStream() throws FileSystemException
There may only be a single input or output stream open for the file at any time.
BufferedInputStream
.FileSystemException
- If the file does not exist, or is being read, or is being written,
or on error opening the stream.OutputStream getOutputStream() throws FileSystemException
There may only be a single input or output stream open for the file at any time.
BufferedOutputStream
.FileSystemException
- If the file is read-only, or is being read, or is being written,
or on error opening the stream.RandomAccessContent getRandomAccessContent(RandomAccessMode mode) throws FileSystemException
There may only be a single input or output stream open for the file at any time.
mode
- The mode to use to access the file.FileSystemException
- If the file is read-only, or is being read, or is being written,
or on error opening the stream.OutputStream getOutputStream(boolean bAppend) throws FileSystemException
There may only be a single input or output stream open for the file at any time.
bAppend
- true if you would like to append to the fileBufferedOutputStream
.FileSystemException
- If the file is read-only, or is being read, or is being written,
or on error opening the stream.void close() throws FileSystemException
This method is a hint to the implementation that it can release resources. This object can continue to be used after calling this method.
FileSystemException
- if an error occurs closing the file.FileContentInfo getContentInfo() throws FileSystemException
FileSystemException
- if an error occurs.boolean isOpen()
Copyright © 2002-2016 The Apache Software Foundation. All Rights Reserved.