| org.apache.commons.vfs.FileContent
All known Subclasses: org.apache.commons.vfs.provider.DefaultFileContent,
FileContent | public interface FileContent (Code) | | Represents the data content of a file.
To read from a file, use the InputStream returned by
FileContent.getInputStream .
To write to a file, use the OutputStream returned by
FileContent.getOutputStream method. This will create the file, and the parent
folder, if necessary.
A file may have multiple InputStreams open at the sametime.
author: Adam Murdoch version: $Revision: 537943 $ $Date: 2007-05-14 11:37:14 -0700 (Mon, 14 May 2007) $ See Also: FileObject.getContent |
Method Summary | |
void | close() Closes all resources used by the content, including any open stream.
Commits pending changes to the file.
This method is a hint to the implementation that it can release
resources. | Object | getAttribute(String attrName) Gets the value of an attribute of the file's content.
Parameters: attrName - The name of the attribute. | String[] | getAttributeNames() Lists the attributes of the file's content.
The names of the attributes. | Map | 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. | public 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.
There may only be a single input or output stream open for the
file at any time.
An input stream to read the file's content from. | long | getLastModifiedTime() Determines the last-modified timestamp of the file. | OutputStream | getOutputStream() Returns an output stream for writing the file's content.
If the file does not exist, this method creates it, and the parent
folder, if necessary. | OutputStream | getOutputStream(boolean bAppend) Returns an output stream for writing the file's content.
If the file does not exist, this method creates it, and the parent
folder, if necessary. | public 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. | public boolean | isOpen() | 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. |
close | void close() throws FileSystemException(Code) | | Closes all resources used by the content, including any open stream.
Commits pending changes to the file.
This method is a hint to the implementation that it can release
resources. This object can continue to be used after calling this
method.
|
getAttribute | Object getAttribute(String attrName) throws FileSystemException(Code) | | Gets the value of an attribute of the file's content.
Parameters: attrName - The name of the attribute. Attribute names are case insensitive. The value of the attribute, or null if the attribute value isunknown. throws: FileSystemException - If the file does not exist, or does not support attributes. |
getAttributeNames | String[] getAttributeNames() throws FileSystemException(Code) | | Lists the attributes of the file's content.
The names of the attributes. Never returns null; throws: FileSystemException - If the file does not exist, or does not support attributes. |
getCertificates | Certificate[] getCertificates() throws FileSystemException(Code) | | Retrieves the certificates if any used to sign this file or folder.
The certificates, or an empty array if there are no certificates orthe file does not support signing. throws: FileSystemException - If the file does not exist, or is being written. |
getFile | FileObject getFile()(Code) | | Returns the file which this is the content of.
|
getInputStream | InputStream getInputStream() throws FileSystemException(Code) | | Returns an input stream for reading the file's content.
There may only be a single input or output stream open for the
file at any time.
An input stream to read the file's content from. The inputstream is buffered, so there is no need to wrap it in aBufferedInputStream . throws: FileSystemException - If the file does not exist, or is being read, or is being written,or on error opening the stream. |
getLastModifiedTime | long getLastModifiedTime() throws FileSystemException(Code) | | Determines the last-modified timestamp of the file.
The last-modified timestamp. throws: FileSystemException - If the file does not exist, or is being written to, or on errordetermining the last-modified timestamp. |
getOutputStream | OutputStream getOutputStream() throws FileSystemException(Code) | | Returns an output stream for writing the file's content.
If the file does not exist, this method creates it, and the parent
folder, if necessary. If the file does exist, it is replaced with
whatever is written to the output stream.
There may only be a single input or output stream open for the
file at any time.
An output stream to write the file's content to. The stream isbuffered, so there is no need to wrap it in aBufferedOutputStream . throws: FileSystemException - If the file is read-only, or is being read, or is being written,or on error opening the stream. |
getOutputStream | OutputStream getOutputStream(boolean bAppend) throws FileSystemException(Code) | | Returns an output stream for writing the file's content.
If the file does not exist, this method creates it, and the parent
folder, if necessary. If the file does exist, it is replaced with
whatever is written to the output stream.
There may only be a single input or output stream open for the
file at any time.
Parameters: bAppend - true if you would like to append to the file An output stream to write the file's content to. The stream isbuffered, so there is no need to wrap it in aBufferedOutputStream . throws: FileSystemException - If the file is read-only, or is being read, or is being written,or on error opening the stream. |
getRandomAccessContent | public RandomAccessContent getRandomAccessContent(RandomAccessMode mode) throws FileSystemException(Code) | | Returns an stream for reading/writing the file's content.
If the file does not exist, and you use one of the write* methods,
this method creates it, and the parent folder, if necessary.
If the file does exist, parts of the file are replaced with whatever is written
at a given position.
There may only be a single input or output stream open for the
file at any time.
throws: FileSystemException - If the file is read-only, or is being read, or is being written,or on error opening the stream. |
getSize | long getSize() throws FileSystemException(Code) | | Determines the size of the file, in bytes.
The size of the file, in bytes. throws: FileSystemException - If the file does not exist, or is being written to, or on errordetermining the size. |
hasAttribute | boolean hasAttribute(String attrName) throws FileSystemException(Code) | | Checks if an attribute of the file's content exists.
Parameters: attrName - The name of the attribute. throws: FileSystemException - If the file does not exist, or does not supportattributes. |
isOpen | public boolean isOpen()(Code) | | check if this file has open streams
|
removeAttribute | void removeAttribute(String attrName) throws FileSystemException(Code) | | Removes the value of an attribute of the file's content.
Parameters: attrName - The name of the attribute. throws: FileSystemException - If the file does not exist, or is read-only, or does not supportattributes, or on error removing the attribute. |
setAttribute | void setAttribute(String attrName, Object value) throws FileSystemException(Code) | | Sets the value of an attribute of the file's content. Creates the
file if it does not exist.
Parameters: attrName - The name of the attribute. Parameters: value - The value of the attribute. throws: FileSystemException - If the file does not exist, or is read-only, or does not supportattributes, or on error setting the attribute. |
setLastModifiedTime | void setLastModifiedTime(long modTime) throws FileSystemException(Code) | | Sets the last-modified timestamp of the file. Creates the file if
it does not exist.
Parameters: modTime - The time to set the last-modified timestamp to. throws: FileSystemException - If the file is read-only, or is being written to, or on errorsetting the last-modified timestamp. |
|
|