public class FileUtils extends Object
| Constructor and Description |
|---|
FileUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
copy(File source,
File destination)
Copy source file or directory into destination file or directory.
|
static boolean |
createDirectory(File destinationFile)
Creates the directory named by this abstract pathname, including any
necessary but nonexistent parent directories.
|
static boolean |
createDirectory(String destinationPath)
Creates the directory named by this abstract pathname, including any
necessary but nonexistent parent directories.
|
static boolean |
delete(File destinationFile)
Deletes the file or directory denoted by this abstract file.
|
static boolean |
delete(String destinationPath)
Deletes the file or directory denoted by this abstract pathname.
|
static File[] |
getAllFilesOfFolder(String folderPath)
Return all files in given folder.
返回给定目录下的所有文件,不包括基子目录下的文件。 |
static byte[] |
getBytes(File source)
Get bytes from given source file.
|
static byte[] |
getBytes(String sourcePath)
Get bytes from given source file path.
|
static boolean |
isDirectory(File destinationFile)
Tests whether the file denoted by this abstract pathname is a directory.
|
static boolean |
isDirectory(String destinationPath)
Tests whether the file denoted by this abstract pathname is a directory.
|
static boolean |
isExist(File destinationFile)
Tests whether the file or directory denoted by this abstract pathname
exists.
|
static boolean |
isExist(String destinationPath)
Tests whether the file or directory denoted by this abstract pathname
exists.
|
static boolean |
write(byte[] sourceBytes,
File destinationFile)
Write source bytes into destination file.
|
static boolean |
write(byte[] sourceBytes,
String destinationPath)
Write source bytes into a file which file path is destination.
|
static boolean |
write(File sourceFile,
File destinationFile)
Write source file bytes into a file which file path is destinationPath.
|
static boolean |
write(File sourceFile,
OutputStream destinationOutputStream)
Write source file bytes into destination output stream.
|
static boolean |
write(File sourceFile,
String destinationPath)
Write source file bytes into a file which file path is destinationPath.
|
static boolean |
write(InputStream sourceInputStream,
File destinationFile)
Write source input stream bytes into destination file.
|
static boolean |
write(InputStream sourceInputStream,
String destinationPath)
Write source input stream bytes into a file which file path is
destinationPath.
|
static boolean |
write(Object sourceInputStream,
String destinationPath)
Write source input stream into a file which file path is
destinationPath(The source input stream must have a method called read
and return bytes).
|
public static boolean isExist(File destinationFile)
destinationFile - public static boolean isExist(String destinationPath)
destinationPath - destination file path or directory path.public static boolean isDirectory(File destinationFile)
destinationFile - file object to be tested.public static boolean isDirectory(String destinationPath)
destinationPath - string path to be tested.public static boolean createDirectory(File destinationFile)
destinationFile - public static boolean createDirectory(String destinationPath)
destinationPath - string path to be handled.public static byte[] getBytes(File source) throws IOException
source - file to be handled.IOExceptionpublic static byte[] getBytes(String sourcePath) throws IOException
sourcePath - string path to be handled.IOExceptionpublic static File[] getAllFilesOfFolder(String folderPath)
folderPath - public static boolean write(InputStream sourceInputStream, File destinationFile) throws IOException
sourceInputStream - input stream to be handled.destinationFile - destination file to be handled.IOExceptionpublic static boolean write(InputStream sourceInputStream, String destinationPath) throws IOException
sourceInputStream - input stream to be handled.destinationPath - destination file path to be handled.IOExceptionpublic static boolean write(File sourceFile, OutputStream destinationOutputStream) throws IOException
sourceFile - source file to be handled.destinationOutputStream - destination output stream to be handled.IOExceptionpublic static boolean write(File sourceFile, File destinationFile) throws IOException
sourceFile - source file to be handled.destinationFile - destination file to be handled.IOExceptionpublic static boolean write(File sourceFile, String destinationPath) throws IOException
sourceFile - source file to be handled.destinationPath - destination file string path to be handled.IOExceptionpublic static boolean write(Object sourceInputStream, String destinationPath) throws IOException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException
sourceInputStream - source input stream to be handled.destinationPath - destination file string path to be handled.IOExceptionSecurityExceptionNoSuchMethodExceptionIllegalArgumentExceptionIllegalAccessExceptionInvocationTargetExceptionInstantiationExceptionpublic static boolean write(byte[] sourceBytes,
File destinationFile)
throws IOException
sourceBytes - source bytes to be handled.destinationFile - destination file to be handles.IOExceptionpublic static boolean write(byte[] sourceBytes,
String destinationPath)
throws IOException
sourceBytes - source bytes to be handled.destinationPath - destination file string path to be handled.IOExceptionpublic static boolean delete(String destinationPath)
destinationPath - file string path to be handled.public static boolean delete(File destinationFile)
destinationFile - public static boolean copy(File source, File destination) throws IOException
source - source file or directory.destination - destination file or directory.IOExceptionCopyright © 2014. All rights reserved.