public final class VFSUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static long |
ONE_GB
The number of bytes in a gigabyte.
|
static long |
ONE_KB
The number of bytes in a kilobyte.
|
static long |
ONE_MB
The number of bytes in a megabyte.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
byteCountToDisplaySize(long size)
Returns a human-readable version of the file size, where the input
represents a specific number of bytes.
|
static boolean |
canWrite(org.apache.commons.vfs2.FileObject fileObject)
Tells whether a file is writable
|
static org.apache.commons.vfs2.FileObject |
createFileObject(String filePath)
Returns a file representation
|
static org.apache.commons.vfs2.FileObject |
createFileSystemRoot(org.apache.commons.vfs2.FileObject fileObject)
Returns the root filesystem of a given file
|
static boolean |
exists(org.apache.commons.vfs2.FileObject fileObject)
Tells whether a file exists
|
static org.apache.commons.vfs2.FileObject[] |
getFiles(org.apache.commons.vfs2.FileObject folder)
Returns all the files of a folder
|
static org.apache.commons.vfs2.FileObject[] |
getFiles(org.apache.commons.vfs2.FileObject folder,
boolean useFileHiding)
Return a folder's files
|
static org.apache.commons.vfs2.FileSystemManager |
getFileSystemManager()
Returns the global filesystem manager
|
static String |
getFriendlyName(String fileName)
Remove user credentials information
|
static String |
getFriendlyName(String fileName,
boolean excludeLocalFilePrefix) |
static InputStream |
getInputStream(org.apache.commons.vfs2.FileObject fileObject)
Returns a buffered input stream from a file
|
static OutputStream |
getOutputStream(org.apache.commons.vfs2.FileObject fileObject)
Returns a buffered output stream from a file
|
static org.apache.commons.vfs2.FileObject |
getParentDirectory(org.apache.commons.vfs2.FileObject fileObject)
Returns the parent directory of a file object
|
static org.apache.commons.vfs2.FileObject |
getRootFileSystem(org.apache.commons.vfs2.FileObject fileObject)
Returns the root file system of a file representation
|
static boolean |
isDirectory(org.apache.commons.vfs2.FileObject fileObject)
Returns whether a file object is a directory
|
static boolean |
isFileSystemRoot(org.apache.commons.vfs2.FileObject folder)
Tells whether a folder is the root filesystem
|
static boolean |
isHiddenFile(org.apache.commons.vfs2.FileObject fileObject)
Tells whether a file is hidden
|
static boolean |
isParent(org.apache.commons.vfs2.FileObject folder,
org.apache.commons.vfs2.FileObject file)
Returns whether a folder contains a given file
|
static boolean |
isRoot(org.apache.commons.vfs2.FileObject fileObject)
Tells whether a file is the root file system
|
static org.apache.commons.vfs2.FileObject |
resolveFileObject(org.apache.commons.vfs2.FileObject folder,
String filename)
Returns a file representation
|
static org.apache.commons.vfs2.FileObject |
resolveFileObject(String filePath)
Returns a file representation
|
static org.apache.commons.vfs2.FileObject |
resolveFileObject(String filePath,
org.apache.commons.vfs2.FileSystemOptions options)
Returns a file representation
|
static void |
setFileSystemManager(org.apache.commons.vfs2.FileSystemManager aFileSystemManager)
Sets the global filesystem manager
|
static void |
setFileSystemOptions(org.apache.commons.vfs2.FileSystemOptions fileSystemOptions) |
static org.apache.commons.vfs2.FileObject |
toFileObject(File file)
Returns a file representation of a local file
|
public static final long ONE_KB
public static final long ONE_MB
public static final long ONE_GB
public static void setFileSystemOptions(org.apache.commons.vfs2.FileSystemOptions fileSystemOptions)
public static org.apache.commons.vfs2.FileSystemManager getFileSystemManager()
public static void setFileSystemManager(org.apache.commons.vfs2.FileSystemManager aFileSystemManager)
aFileSystemManager - the global filesystem managerpublic static String byteCountToDisplaySize(long size)
size - the number of bytespublic static InputStream getInputStream(org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
fileObject - A file objectorg.apache.commons.vfs2.FileSystemException - An exception while getting the filepublic static OutputStream getOutputStream(org.apache.commons.vfs2.FileObject fileObject) throws org.apache.commons.vfs2.FileSystemException
fileObject - A file objectorg.apache.commons.vfs2.FileSystemException - An exception while getting the filepublic static boolean canWrite(org.apache.commons.vfs2.FileObject fileObject)
fileObject - public static org.apache.commons.vfs2.FileObject createFileObject(String filePath)
filePath - The file pathpublic static final String getFriendlyName(String fileName)
fileName - The file namepublic static final String getFriendlyName(String fileName, boolean excludeLocalFilePrefix)
public static org.apache.commons.vfs2.FileObject createFileSystemRoot(org.apache.commons.vfs2.FileObject fileObject)
fileObject - A filepublic static org.apache.commons.vfs2.FileObject[] getFiles(org.apache.commons.vfs2.FileObject folder)
folder - A folderpublic static org.apache.commons.vfs2.FileObject[] getFiles(org.apache.commons.vfs2.FileObject folder,
boolean useFileHiding)
folder - A folder abstractionuseFileHiding - flag to include hidden filespublic static org.apache.commons.vfs2.FileObject getRootFileSystem(org.apache.commons.vfs2.FileObject fileObject)
fileObject - A file abstractionpublic static boolean isHiddenFile(org.apache.commons.vfs2.FileObject fileObject)
fileObject - a file representationpublic static boolean isRoot(org.apache.commons.vfs2.FileObject fileObject)
fileObject - A file representationpublic static org.apache.commons.vfs2.FileObject toFileObject(File file)
file - a local filepublic static org.apache.commons.vfs2.FileObject getParentDirectory(org.apache.commons.vfs2.FileObject fileObject)
fileObject - A file representationpublic static org.apache.commons.vfs2.FileObject resolveFileObject(String filePath)
filePath - The file pathpublic static org.apache.commons.vfs2.FileObject resolveFileObject(String filePath, org.apache.commons.vfs2.FileSystemOptions options)
filePath - The file pathoptions - The filesystem optionspublic static org.apache.commons.vfs2.FileObject resolveFileObject(org.apache.commons.vfs2.FileObject folder,
String filename)
folder - A folderfilename - A filenamepublic static boolean exists(org.apache.commons.vfs2.FileObject fileObject)
fileObject - A file representationpublic static boolean isDirectory(org.apache.commons.vfs2.FileObject fileObject)
fileObject - A file object representationpublic static boolean isFileSystemRoot(org.apache.commons.vfs2.FileObject folder)
folder - A folderpublic static boolean isParent(org.apache.commons.vfs2.FileObject folder,
org.apache.commons.vfs2.FileObject file)
folder - A folderfile - A fileCopyright © 2020. All rights reserved.