public class FileUtil extends Object
IOException and output error logs| 限定符和类型 | 方法和说明 |
|---|---|
static void |
close(Channel channel)
Close the
Channel |
static void |
close(InputStream inputStream)
Close the
InputStream |
static void |
close(OutputStream outputStream)
Close the
OutputStream |
static void |
close(Reader br)
Close the
Reader |
static void |
close(Writer bw)
Close the
Writer |
static void |
copyFolder(String srcPath,
String descPath,
boolean moveSubFolder)
Copy a directory to a new path
|
static void |
cp_R(Path srcPath,
Path descPath)
Copy a directory to a new path
|
static void |
cp_R(Path srcPath,
Path descPath,
boolean moveSubFolder)
Copy a directory to a new path
|
static void |
cp_R(String srcPath,
String descPath)
Copy a directory to a new path
|
static void |
cp_R(String srcPath,
String descPath,
boolean moveSubFolder)
Copy a directory to a new path
|
static void |
cp(File srcFile,
File descFile)
Copy a single file
|
static void |
cp(InputStream is,
Path descFile)
Copy a single file
|
static void |
cp(Path srcPath,
File descFile)
Copy a single file
|
static boolean |
exists(Path path)
Tests whether a file exists.
|
static boolean |
isWindows()
Test current OS system is windows family
|
static Path |
mkdir(Path destPath)
Create a directory
|
static Path |
mktmp(String prefix)
Create a temp directory
|
static void |
rm_rf(File root,
boolean rmSelf)
Remove file and sub-files if it a directory
|
static void |
rm_rf(Path root)
Remove file and sub-files if it a directory
|
static void |
rm(File file)
Delete if exists file
|
static void |
rm(Path path)
Delete if exists file
|
static void |
writeToDisk(org.dom4j.Document doc,
Path path)
Write the
Document to a specify Path
with xml format |
static void |
writeToDiskNoFormat(org.dom4j.Document doc,
Path path)
Write the
Document to a specify Path |
public static void close(InputStream inputStream)
InputStreaminputStream - the in streampublic static void close(OutputStream outputStream)
OutputStreamoutputStream - the out streampublic static void rm(Path path)
path - the file path to be deletepublic static void rm(File file)
file - the file to be deletepublic static void rm_rf(Path root)
root - the root pathpublic static void rm_rf(File root, boolean rmSelf)
root - the root pathrmSelf - remove self if truepublic static void cp(Path srcPath, File descFile)
srcPath - the source pathdescFile - the destination filepublic static void cp(File srcFile, File descFile)
srcFile - the source filedescFile - the destination filepublic static void cp(InputStream is, Path descFile)
is - the source input streamdescFile - the destination pathpublic static void cp_R(String srcPath, String descPath, boolean moveSubFolder)
srcPath - the source path stringdescPath - the destination path stringmoveSubFolder - need move sub-folderspublic static void cp_R(Path srcPath, Path descPath, boolean moveSubFolder)
srcPath - the source pathdescPath - the destination pathmoveSubFolder - need move sub-folderspublic static void cp_R(String srcPath, String descPath)
srcPath - the source path stringdescPath - the destination path stringpublic static void cp_R(Path srcPath, Path descPath)
srcPath - the source pathdescPath - the destination pathpublic static void copyFolder(String srcPath, String descPath, boolean moveSubFolder)
srcPath - the source path stringdescPath - the destination path stringmoveSubFolder - need move sub-folderspublic static Path mkdir(Path destPath) throws IOException
destPath - the destination directory pathIOException - if I/O error occurpublic static Path mktmp(String prefix) throws IOException
prefix - the directory prefixIOException - if I/O error occurpublic static boolean isWindows()
public static void writeToDisk(org.dom4j.Document doc,
Path path)
throws IOException
Document to a specify Path
with xml formatdoc - the Documentpath - the output pathIOException - if I/O error occurpublic static void writeToDiskNoFormat(org.dom4j.Document doc,
Path path)
throws IOException
Document to a specify Pathdoc - the Documentpath - the output pathIOException - if I/O error occurpublic static boolean exists(Path path)
path - the path to the file to testCopyright © 2022. All rights reserved.