|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.io.FileUtils
org.mule.util.FileUtils
public class FileUtils
FileUtils
contains useful methods for dealing with files &
directories.
Field Summary | |
---|---|
static String |
DEFAULT_ENCODING
|
Fields inherited from class org.apache.commons.io.FileUtils |
---|
EMPTY_FILE_ARRAY, ONE_GB, ONE_KB, ONE_MB |
Constructor Summary | |
---|---|
FileUtils()
|
Method Summary | |
---|---|
static void |
copyStreamToFile(InputStream input,
File destination)
|
static File |
createFile(String filename)
|
static boolean |
deleteTree(File dir)
Delete a file tree recursively. |
static boolean |
deleteTree(File dir,
String[] topLevelDirsToIgnore)
Delete a file tree recursively. |
static void |
extractResources(String resourceName,
Class callingClass,
File outputDir,
boolean keepParentDirectory)
Extract the specified resource to the given directory for remain all directory struct |
static String |
getResourcePath(String resourceName,
Class callingClass)
|
static String |
getResourcePath(String resourceName,
Class callingClass,
String encoding)
|
static boolean |
moveFile(File sourceFile,
File destinationFile)
Try to move a file by renaming with backup attempt by copying/deleting via NIO |
static File |
newFile(File parent,
String child)
Workaround for JDK bug 4117557. |
static File |
newFile(String pathName)
Workaround for JDK bug 4117557. |
static File |
newFile(String parent,
String child)
Workaround for JDK bug 4117557. |
static File |
newFile(URI uri)
Workaround for JDK bug 4117557. |
static String |
normalizeFilePath(URL url,
String encoding)
Remove from uri to file prefix file:/ Add if need file separator to begin |
static File |
openDirectory(String directory)
|
static String |
prepareWinFilename(String filename)
|
static boolean |
renameFile(File srcFile,
File destFile)
|
static boolean |
renameFile(String srcFilePath,
String destFilePath)
|
static boolean |
renameFileHard(File srcFile,
File destFile)
|
static boolean |
renameFileHard(String srcFilePath,
String destFilePath)
|
static void |
safeCopyFile(File in,
File out)
Copy in file to out file Don't use java.nio as READ_ONLY memory mapped files cannot be deleted |
static File |
stringToFile(String filename,
String data)
Reads the incoming String into a file at at the given destination. |
static File |
stringToFile(String filename,
String data,
boolean append)
|
static File |
stringToFile(String filename,
String data,
boolean append,
boolean newLine)
|
static void |
unzip(File archive,
File directory)
Unzip the specified archive to the given directory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_ENCODING
Constructor Detail |
---|
public FileUtils()
Method Detail |
---|
public static void copyStreamToFile(InputStream input, File destination) throws IOException
IOException
public static File createFile(String filename) throws IOException
IOException
public static String prepareWinFilename(String filename)
public static File openDirectory(String directory) throws IOException
IOException
public static File stringToFile(String filename, String data) throws IOException
filename
- name and path of the file to createdata
- the contents of the file
IOException
- If the creating or writing to the file stream failspublic static File stringToFile(String filename, String data, boolean append) throws IOException
IOException
public static File stringToFile(String filename, String data, boolean append, boolean newLine) throws IOException
IOException
public static String getResourcePath(String resourceName, Class callingClass) throws IOException
IOException
public static String getResourcePath(String resourceName, Class callingClass, String encoding) throws IOException
IOException
public static String normalizeFilePath(URL url, String encoding) throws UnsupportedEncodingException
url
- file uri to resourceencoding
- - Java encoding names
UnsupportedEncodingException
- if encoding is unknownpublic static boolean deleteTree(File dir)
dir
- dir to wipe out
public static boolean deleteTree(File dir, String[] topLevelDirsToIgnore)
dir
- dir to wipe outtopLevelDirsToIgnore
- which top-level directories to ignore,
if null or empty then ignored
public static void unzip(File archive, File directory) throws IOException
IOException
public static File newFile(String pathName)
java.io.File class
.
No physical file created in this method.
File
public static File newFile(URI uri)
java.io.File class
.
No physical file created in this method.
File
public static File newFile(File parent, String child)
java.io.File class
.
No physical file created in this method.
File
public static File newFile(String parent, String child)
java.io.File class
.
No physical file created in this method.
File
public static void extractResources(String resourceName, Class callingClass, File outputDir, boolean keepParentDirectory) throws IOException
resourceName
- - full resource namecallingClass
- - classloader for this class is usedoutputDir
- - extract to this directorykeepParentDirectory
- true - full structure of directories is kept; false - file - removed all directories, directory - started from resource point
IOException
- if any errorspublic static boolean renameFileHard(String srcFilePath, String destFilePath)
public static boolean renameFileHard(File srcFile, File destFile)
public static boolean renameFile(String srcFilePath, String destFilePath)
public static boolean renameFile(File srcFile, File destFile)
public static boolean moveFile(File sourceFile, File destinationFile)
public static void safeCopyFile(File in, File out) throws IOException
in
- out
-
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |