|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.muse.util.FileUtils
public final class FileUtils
FileUtils is a collection of routines for common file system operations.
Field Summary | |
---|---|
static File |
CURRENT_DIR
The application's current working directory. |
Constructor Summary | |
---|---|
FileUtils()
|
Method Summary | |
---|---|
static void |
close(InputStream stream)
This is a convenience method that throws an unchecked exception if the stream could not be closed. |
static void |
close(OutputStream stream)
This is a convenience method that throws an unchecked exception if the stream could not be closed. |
static void |
close(Reader reader)
This is a convenience method that throws an unchecked exception if the reader could not be closed. |
static void |
close(Writer writer)
This is a convenience method that throws an unchecked exception if the writer could not be closed. |
static void |
copy(File source,
File destination)
Copies the first file or directory to the second file or directory. |
static void |
copyDirectory(File source,
File destination)
|
static void |
copyDirectory(File source,
File destination,
FileFilter filter)
|
static void |
copyFile(File source,
File destination)
|
static void |
copyFile(InputStream input,
File destination)
|
static String |
createRelativePath(String originalPath,
String relativePath)
Merges the two paths to create a valid version of the second path. |
static File |
find(File contextRoot,
String fileName)
This is a convenience method that calls find(File, String, boolean) with the last parameter set to "false" (does not match directories). |
static File |
find(File contextRoot,
String fileName,
boolean matchDirectories)
Searches through the directory tree under the given context directory and finds the first file that matches the file name. |
static InputStream |
loadFromContext(Class context,
String path)
Gets a java.io.File using a path that is relative to the context of the given Class. |
static String |
makePath(String[] strings)
Convert a list of path elements to a platform-specific path. |
static void |
pruneEmptyDirectories(File directory)
Starts at the directory given and tests to see whether it is empty; if so, it deletes it and moves up the directory tree, deleting empty directories until it finds a non-empty one. |
static void |
remove(File file)
This is a convenience method that calls remove(File, boolean) with the second parameter set to "false" (doesn't prune empty directories). |
static void |
remove(File file,
boolean pruneEmptyDirectories)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final File CURRENT_DIR
Constructor Detail |
---|
public FileUtils()
Method Detail |
---|
public static void close(InputStream stream)
public static void close(OutputStream stream)
public static void close(Reader reader)
public static void close(Writer writer)
public static void copy(File source, File destination) throws IOException
source
- destination
-
IOException
- public static void copyDirectory(File source, File destination) throws IOException
IOException
public static void copyDirectory(File source, File destination, FileFilter filter) throws IOException
IOException
public static void copyFile(File source, File destination) throws IOException
IOException
public static void copyFile(InputStream input, File destination) throws IOException
IOException
public static String createRelativePath(String originalPath, String relativePath)
originalPath
- The path of the file that references another file.relativePath
- The path of the other file, which is relative to the original.
public static File find(File contextRoot, String fileName)
find(File, String, boolean)
public static File find(File contextRoot, String fileName, boolean matchDirectories)
contextRoot
- The directory to start the search from.fileName
- The name of the file (or directory) to search for.matchDirectories
- True if the method should try and match the name against
directory names, not just file names.
public static InputStream loadFromContext(Class context, String path)
context
- The classpath from which to load.path
- The context-relative file path.
public static String makePath(String[] strings)
strings
- Elements in a path
File.separator
public static void pruneEmptyDirectories(File directory) throws IOException
directory
- The first directory to test.
IOException
- public static void remove(File file) throws IOException
IOException
remove(File, boolean)
public static void remove(File file, boolean pruneEmptyDirectories) throws IOException
file
- The file or directory to delete.pruneEmptyDirectories
- True if the deletion results in an empty parent directory. If
set to true, this method will traverse up the directory tree,
deleting directories that are made empty by the deletion.
IOException
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |