Package org.apache.commons.vfs2.util
Class FileObjectUtils
java.lang.Object
org.apache.commons.vfs2.util.FileObjectUtils
Utility methods for 
FileObject.- 
Method SummaryModifier and TypeMethodDescriptionstatic booleanexists(FileObject fileObject) Null-safe call toFileObject.exists().static AbstractFileObjectgetAbstractFileObject(FileObject fileObject) Gets access to the base object even if decorated.static byte[]Gets the content of a file object, as a byte array.static StringgetContentAsString(FileObject file, String charset) Returns the content of a file as a String.static StringgetContentAsString(FileObject file, Charset charset) Gets the content of a file as a String.static booleanisInstanceOf(FileObject fileObject, Class<?> wantedClass) Checks if the given FileObject is instance of given class argument.static PropertiesreadProperties(FileObject fileObject) Reads the given file into a newProperties.static PropertiesreadProperties(FileObject fileObject, Properties properties) Reads the given file into a new givenProperties.static voidwriteContent(FileObject file, OutputStream output) Writes the content of a file to an OutputStream.static voidwriteContent(FileObject srcFile, FileObject destFile) Writes the content from a source file to a destination file.
- 
Method Details- 
existsNull-safe call toFileObject.exists().- Parameters:
- fileObject- the file object to test, may be null.
- Returns:
- false if fileObjectis null, otherwise, seeFileObject.exists().
- Throws:
- FileSystemException- On error determining if this file exists.
- Since:
- 2.4
 
- 
getAbstractFileObjectpublic static AbstractFileObject getAbstractFileObject(FileObject fileObject) throws FileSystemException Gets access to the base object even if decorated.- Parameters:
- fileObject- The FileObject.
- Returns:
- The decorated FileObject or null.
- Throws:
- FileSystemException- if an error occurs.
 
- 
getContentAsByteArrayGets the content of a file object, as a byte array.- Parameters:
- file- Gets the contents of this file object.
- Returns:
- The content as a byte array.
- Throws:
- IOException- if the file content cannot be accessed.
- Since:
- 2.6.0
 
- 
getContentAsStringGets the content of a file as a String.- Parameters:
- file- Gets the contents of this file object.
- charset- The file character set, may be null.
- Returns:
- The content as a string.
- Throws:
- IOException- if the file content cannot be accessed.
- Since:
- 2.4
 
- 
getContentAsStringReturns the content of a file as a String.- Parameters:
- file- Gets the contents of this file object.
- charset- The file character set, may be null.
- Returns:
- The content as a string.
- Throws:
- IOException- if the file content cannot be accessed.
- Since:
- 2.4
 
- 
isInstanceOfpublic static boolean isInstanceOf(FileObject fileObject, Class<?> wantedClass) throws FileSystemException Checks if the given FileObject is instance of given class argument.- Parameters:
- fileObject- The FileObject.
- wantedClass- The Class to check.
- Returns:
- true if fileObject is an instance of the specified Class.
- Throws:
- FileSystemException- if an error occurs.
 
- 
readPropertiespublic static Properties readProperties(FileObject fileObject) throws FileSystemException, IOException Reads the given file into a newProperties.- Parameters:
- fileObject- the file to read
- Returns:
- a new Properties.
- Throws:
- IOException- On error getting this file's content.
- FileSystemException- On error getting this file's content.
- IOException- On error getting this file's content.
- Since:
- 2.4
 
- 
readPropertiespublic static Properties readProperties(FileObject fileObject, Properties properties) throws FileSystemException, IOException Reads the given file into a new givenProperties.- Parameters:
- fileObject- the file to read
- properties- the destination
- Returns:
- a new Properties.
- Throws:
- FileSystemException- On error getting this file's content.
- IOException- On error getting this file's content.
- Since:
- 2.4
 
- 
writeContentWrites the content from a source file to a destination file.- Parameters:
- srcFile- The source FileObject.
- destFile- The target FileObject
- Throws:
- IOException- If an error occurs copying the file.
- Since:
- 2.6.0
- See Also:
 
- 
writeContentWrites the content of a file to an OutputStream.- Parameters:
- file- The FileObject to write.
- output- The OutputStream to write to.
- Throws:
- IOException- if an error occurs writing the file.
- Since:
- 2.6.0
- See Also:
 
 
-