public final class FileObjectUtils extends Object
FileObject.| Modifier and Type | Method and Description |
|---|---|
static boolean |
exists(FileObject fileObject)
Null-safe call to
FileObject.exists(). |
static AbstractFileObject |
getAbstractFileObject(FileObject fileObject)
Gets access to the base object even if decorated.
|
static byte[] |
getContentAsByteArray(FileObject file)
Gets the content of a file object, as a byte array.
|
static String |
getContentAsString(FileObject file,
Charset charset)
Gets the content of a file as a String.
|
static String |
getContentAsString(FileObject file,
String charset)
Returns the content of a file as a String.
|
static boolean |
isInstanceOf(FileObject fileObject,
Class<?> wantedClass)
Checks if the given FileObject is instance of given class argument.
|
static Properties |
readProperties(FileObject fileObject)
Reads the given file into a new
Properties. |
static Properties |
readProperties(FileObject fileObject,
Properties properties)
Reads the given file into a new given
Properties. |
static void |
writeContent(FileObject srcFile,
FileObject destFile)
Writes the content from a source file to a destination file.
|
static void |
writeContent(FileObject file,
OutputStream output)
Writes the content of a file to an OutputStream.
|
public static boolean exists(FileObject fileObject) throws FileSystemException
FileObject.exists().fileObject - the file object to test, may be null.fileObject is null, otherwise, see FileObject.exists().FileSystemException - On error determining if this file exists.public static AbstractFileObject getAbstractFileObject(FileObject fileObject) throws FileSystemException
fileObject - The FileObject.FileSystemException - if an error occurs.public static byte[] getContentAsByteArray(FileObject file) throws IOException
file - Gets the contents of this file object.IOException - if the file content cannot be accessed.public static String getContentAsString(FileObject file, Charset charset) throws IOException
file - Gets the contents of this file object.charset - The file character set, may be null.IOException - if the file content cannot be accessed.public static String getContentAsString(FileObject file, String charset) throws IOException
file - Gets the contents of this file object.charset - The file character set, may be null.IOException - if the file content cannot be accessed.public static boolean isInstanceOf(FileObject fileObject, Class<?> wantedClass) throws FileSystemException
fileObject - The FileObject.wantedClass - The Class to check.FileSystemException - if an error occurs.public static Properties readProperties(FileObject fileObject) throws FileSystemException, IOException
Properties.fileObject - the file to readProperties.IOException - On error getting this file's content.FileSystemException - On error getting this file's content.IOException - On error getting this file's content.public static Properties readProperties(FileObject fileObject, Properties properties) throws FileSystemException, IOException
Properties.fileObject - the file to readproperties - the destinationProperties.FileSystemException - On error getting this file's content.IOException - On error getting this file's content.public static void writeContent(FileObject srcFile, FileObject destFile) throws IOException
srcFile - The source FileObject.destFile - The target FileObjectIOException - If an error occurs copying the file.FileContent.write(FileObject)public static void writeContent(FileObject file, OutputStream output) throws IOException
file - The FileObject to write.output - The OutputStream to write to.IOException - if an error occurs writing the file.FileContent.write(OutputStream)Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.