Class DefaultFileContent
java.lang.Object
org.apache.commons.vfs2.provider.DefaultFileContent
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultFileContent(AbstractFileObject fileObject, FileContentInfoFactory fileContentInfoFactory) Constructs a new instance.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Closes all resources used by the content, including all streams, readers and writers.getAttribute(String attrName) Gets the value of an attribute.String[]Lists the attributes of this file.Returns a read-only map of this file's attributes.Returns the certificates used to sign this file.Gets the FileContentInfo which describes the content-type, content-encoding.getFile()Returns the file that this is the content of.Returns an input stream for reading the content.getInputStream(int bufferSize) Returns an input stream for reading the content.longReturns the last-modified timestamp.Returns an output stream for writing the content.getOutputStream(boolean bAppend) Returns an output stream for writing the content in append mode.getOutputStream(boolean bAppend, int bufferSize) Returns an output stream for writing the content in append mode.getOutputStream(int bufferSize) Returns an output stream for writing the content.Returns an input/output stream to use to read and write the content of the file in a random manner.longgetSize()Returns the size of the content (in bytes).booleanhasAttribute(String attrName) Checks if an attribute exists.booleanisOpen()Checks if an input and/or output stream is open.booleanChecks if an input or output stream is open.voidremoveAttribute(String attrName) Removes an attribute.voidUsed internally to flag situations where the file attributes should be retrieved again.voidsetAttribute(String attrName, Object value) Sets the value of an attribute.voidsetLastModifiedTime(long modTime) Sets the last-modified timestamp.longwrite(OutputStream output) Writes this content to an OutputStream.longwrite(OutputStream output, int bufferSize) Copies this content to an OutputStream.longwrite(FileContent fileContent) Writes this content to another FileContent.longwrite(FileObject file) Writes this content to another FileObject.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.vfs2.FileContentgetByteArray, getString, getString, isEmpty
- 
Constructor Details- 
DefaultFileContentpublic DefaultFileContent(AbstractFileObject fileObject, FileContentInfoFactory fileContentInfoFactory) Constructs a new instance.- Parameters:
- fileObject- The file object.
- fileContentInfoFactory- The info factory.
 
 
- 
- 
Method Details- 
closeCloses all resources used by the content, including all streams, readers and writers.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- FileContent
- Throws:
- FileSystemException- if an error occurs.
 
- 
getAttributeGets the value of an attribute.- Specified by:
- getAttributein interface- FileContent
- Parameters:
- attrName- The attribute name.
- Returns:
- The value of the attribute or null.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getAttributeNamesLists the attributes of this file.- Specified by:
- getAttributeNamesin interface- FileContent
- Returns:
- An array of attribute names.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getAttributesReturns a read-only map of this file's attributes.- Specified by:
- getAttributesin interface- FileContent
- Returns:
- a Map of the file's attributes.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getCertificatesReturns the certificates used to sign this file.- Specified by:
- getCertificatesin interface- FileContent
- Returns:
- An array of Certificates.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getContentInfoGets the FileContentInfo which describes the content-type, content-encoding.- Specified by:
- getContentInfoin interface- FileContent
- Returns:
- The FileContentInfo.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getFileReturns the file that this is the content of.- Specified by:
- getFilein interface- FileContent
- Returns:
- the FileObject.
 
- 
getInputStreamReturns an input stream for reading the content.- Specified by:
- getInputStreamin interface- FileContent
- Returns:
- The InputStream
- Throws:
- FileSystemException- if an error occurs.
 
- 
getInputStreamReturns an input stream for reading the content.- Specified by:
- getInputStreamin interface- FileContent
- Parameters:
- bufferSize- The buffer size to use.
- Returns:
- The InputStream
- Throws:
- FileSystemException- if an error occurs.
- Since:
- 2.4
 
- 
getLastModifiedTimeReturns the last-modified timestamp.- Specified by:
- getLastModifiedTimein interface- FileContent
- Returns:
- The last modified timestamp.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getOutputStreamReturns an output stream for writing the content.- Specified by:
- getOutputStreamin interface- FileContent
- Returns:
- The OutputStream for the file.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getOutputStreamReturns an output stream for writing the content in append mode.- Specified by:
- getOutputStreamin interface- FileContent
- Parameters:
- bAppend- true if the data written should be appended.
- Returns:
- The OutputStream for the file.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getOutputStreamReturns an output stream for writing the content in append mode.- Specified by:
- getOutputStreamin interface- FileContent
- Parameters:
- bAppend- true if the data written should be appended.
- bufferSize- The buffer size to use.
- Returns:
- The OutputStream for the file.
- Throws:
- FileSystemException- if an error occurs.
- Since:
- 2.4
 
- 
getOutputStreamReturns an output stream for writing the content.- Specified by:
- getOutputStreamin interface- FileContent
- Parameters:
- bufferSize- The buffer size to use.
- Returns:
- The OutputStream for the file.
- Throws:
- FileSystemException- if an error occurs.
- Since:
- 2.4
 
- 
getRandomAccessContentReturns an input/output stream to use to read and write the content of the file in a random manner.- Specified by:
- getRandomAccessContentin interface- FileContent
- Parameters:
- mode- The RandomAccessMode.
- Returns:
- A RandomAccessContent object to access the file.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getSizeReturns the size of the content (in bytes).- Specified by:
- getSizein interface- FileContent
- Returns:
- The size of the content (in bytes).
- Throws:
- FileSystemException- if an error occurs.
 
- 
hasAttributeChecks if an attribute exists.- Specified by:
- hasAttributein interface- FileContent
- Parameters:
- attrName- The name of the attribute to check.
- Returns:
- true if the attribute is associated with the file.
- Throws:
- FileSystemException- if an error occurs.
- Since:
- 2.0
 
- 
isOpenChecks if an input and/or output stream is open.This checks only the scope of the current thread. - Specified by:
- isOpenin interface- FileContent
- Returns:
- true if this is the case
 
- 
isOpenGlobalChecks if an input or output stream is open. This checks all threads.- Returns:
- true if this is the case
 
- 
removeAttributeRemoves an attribute.- Specified by:
- removeAttributein interface- FileContent
- Parameters:
- attrName- The name of the attribute to remove.
- Throws:
- FileSystemException- if an error occurs.
- Since:
- 2.0
 
- 
resetAttributesUsed internally to flag situations where the file attributes should be retrieved again.- Since:
- 2.0
 
- 
setAttributeSets the value of an attribute.- Specified by:
- setAttributein interface- FileContent
- Parameters:
- attrName- The name of the attribute to add.
- value- The value of the attribute.
- Throws:
- FileSystemException- if an error occurs.
 
- 
setLastModifiedTimeSets the last-modified timestamp.- Specified by:
- setLastModifiedTimein interface- FileContent
- Parameters:
- modTime- The last modified timestamp.
- Throws:
- FileSystemException- if an error occurs.
 
- 
writeWrites this content to another FileContent.- Specified by:
- writein interface- FileContent
- Parameters:
- fileContent- The target FileContent.
- Returns:
- the total number of bytes written
- Throws:
- IOException- if an error occurs writing the content.
- Since:
- 2.1
 
- 
writeWrites this content to another FileObject.- Specified by:
- writein interface- FileContent
- Parameters:
- file- The target FileObject.
- Returns:
- the total number of bytes written
- Throws:
- IOException- if an error occurs writing the content.
- Since:
- 2.1
 
- 
writeWrites this content to an OutputStream.- Specified by:
- writein interface- FileContent
- Parameters:
- output- The target OutputStream.
- Returns:
- the total number of bytes written
- Throws:
- IOException- if an error occurs writing the content.
- Since:
- 2.1
 
- 
writeCopies this content to an OutputStream.- Specified by:
- writein interface- FileContent
- Parameters:
- output- The target OutputStream.
- bufferSize- The buffer size to write data chunks.
- Returns:
- the total number of bytes written.
- Throws:
- IOException- if an error occurs writing the file.
- Since:
- 2.1
 
 
-