|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.glaivestone.javax.io.FileSystemServices
Convenience services for working with files and directories in a file system.
The standard service provider for the host file system is accessed
by referencing FileSystemServices.getCurrent()
.
Field Summary | |
static FileSystemServices |
current
|
static int |
DEFAULT_COPY_BUFFER_SIZE
Default size in bytes of the transfer buffer used by the copyFile operation. |
Constructor Summary | |
FileSystemServices(int copyBufferSize)
Create a new FileSystemServices instance which will use
a copy buffer of the specified size in bytes for invocations
of the copyFile operation. |
Method Summary | |
void |
clearCopyBuffer()
Clear the transfer buffer used by the copyFile operation. |
void |
copyFile(java.io.File sourceFile,
java.io.File destination)
Copy the contents of the source file to the destination file system element. |
FileSystemOperationResult |
deleteAllFiles(java.io.File aDirectory)
Delete all files in the specified directory and its subdirectories. |
FileSystemOperationResult |
deleteDirectory(java.io.File aDirectory)
Delete the contents of the specified directory and all its subdirectories. |
FileSystemOperationResult |
deleteEmptyDirectories(java.io.File aDirectory)
Delete all empty subdirectories under the given directory, along with the root directory itself if empty. |
FileSystemOperationResult |
deleteEmptySubdirectories(java.io.File aDirectory)
Delete all empty subdirectories under the given directory. |
FileSystemOperationResult |
deleteFiles(java.io.File aDirectory)
Delete all files in the specified directory. |
static FileSystemServices |
getCurrent()
|
int |
getDirectorySize(java.io.File aDirectory)
Answer the number of file system elements (files and directories) which are directly contained in the given directory. |
java.lang.String |
getFileContents(java.io.File aFile)
Answer a string containing the contents of the specified file. |
java.lang.String |
getFileContents(java.lang.String pathname)
Answer a string containing the contents of the specified file. |
char[] |
getFileContentsAsCharArray(java.io.File aFile)
Answer a character array containing the contents of the specified file. |
boolean |
isRealDirectory(java.io.File fileSystemElement)
Answer whether the given file system element is a directory which actually exists. |
java.io.File |
realizeDirectory(java.io.File aDirectory)
Ensure that the specified directory exists. |
java.io.File |
realizeDirectory(java.io.File aDirectory,
java.lang.String relativePathName)
Ensure that the specified directory exists. |
void |
setCopyBufferSize(int nBytes)
Specify the size in bytes of the transfer buffer used by the copyFile operation. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_COPY_BUFFER_SIZE
copyFile
operation.
public static FileSystemServices current
Constructor Detail |
public FileSystemServices(int copyBufferSize)
FileSystemServices
instance which will use
a copy buffer of the specified size in bytes for invocations
of the copyFile
operation.
Method Detail |
public static FileSystemServices getCurrent()
public void clearCopyBuffer()
copyFile
operation.
public void copyFile(java.io.File sourceFile, java.io.File destination) throws java.io.FileNotFoundException, java.io.IOException
It's very discouraging that this fundamental service
is not exposed in the base system File
class.
java.io.FileNotFoundException
- thrown if the source file cannot be accessed
java.io.IOException
- thrown if the destination file cannot be created or copying failspublic FileSystemOperationResult deleteAllFiles(java.io.File aDirectory)
public FileSystemOperationResult deleteDirectory(java.io.File aDirectory)
public FileSystemOperationResult deleteEmptyDirectories(java.io.File aDirectory)
public FileSystemOperationResult deleteEmptySubdirectories(java.io.File aDirectory)
public FileSystemOperationResult deleteFiles(java.io.File aDirectory)
public int getDirectorySize(java.io.File aDirectory)
public java.lang.String getFileContents(java.io.File aFile) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public java.lang.String getFileContents(java.lang.String pathname) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public char[] getFileContentsAsCharArray(java.io.File aFile) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public boolean isRealDirectory(java.io.File fileSystemElement)
Returns false if the path refers to a directory which has not yet been realized in the file system or if the path is a reference to a file.
public java.io.File realizeDirectory(java.io.File aDirectory, java.lang.String relativePathName) throws java.io.IOException
Creates the directory and any containing directory structure if necessary.
java.io.IOException
- If the named directory and all necessary parent directories
could not be createdpublic java.io.File realizeDirectory(java.io.File aDirectory) throws java.io.IOException
Creates the directory and any containing directory structure if necessary.
java.io.IOException
- If the named directory and all necessary parent directories
could not be createdpublic void setCopyBufferSize(int nBytes)
copyFile
operation.
|
GFL 1.1 API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |