apache-comnons系列之commons-io-2.5 org.apache.commons.io.FileUtils学习笔记
2017-07-22 00:19
337 查看
apache-comnons系列之commons-io-2.5 org.apache.commons.io.FileUtils学习笔记
概述
Facilities are provided in the following areas:writing to a file
reading from a file
converting to and from a URL
comparing file content
file last changed date
calculating a checksum
make a directory including parent directories
copying files and directories
deleting files and directories
listing files and directories by filter and extension
测试
org.apache.commons.io.FileUtilsTestCasedirectory
forceMkdir
Makes a directory, including any necessary but nonexistent parent directories.
copyFile
This method copies the contents of the specified source file to the specified destination file. The directory holding the destination file is created if it does not exist. If the destination file exists, then this method will overwrite it
doCopyFile完成复制
deleteDirectory
Deletes a directory recursively
cleanDirectory/directory.delete
listFiles
Finds files within a given directory (and optionally its subdirectories). All files found are filtered by an IOFileFilter.
innerListFiles–FileFilterUtils.or–directory.listFiles((FileFilter) filter)
file
getFile/toFile
Construct a file from the set of name elements
openInputStream/openOutputStream
toURLs
Converts each of an array of
Fileto a
URL.
isFileNewer
Tests if the specified
Fileis newer than the reference
File.
byteCountToDisplaySize
Returns a human-readable version of the file size, where the input represents a specific number of bytes
contentEquals
This method checks to see if the two files are different lengths or if they point to the same file, before resorting to byte-by-byte comparison of the contents.
IOUtils.contentEquals(input1, input2)
FilenameUtils
This class defines six components within a filename(example C:\dev\project\file.txt):
the prefix - C:\
the path - dev\project\
the full path - C:\dev\project\
the name - file.txt
the base name - file
the extension - txt
相关文章推荐
- apache-comnons系列之commons-io-2.5 org.apache.commons.io.IOUtils学习笔记
- Tomcat中使用commons-io-2.5发生的错误java.lang.ClassNotFoundException- org.apache.commons.io.IOUtils
- Tomcat中使用commons-io-2.5发生的错误java.lang.ClassNotFoundException: org.apache.commons.io.IOUtils
- Unable to parse request org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processi
- apache-comnons系列之commons-configuration2 学习笔记
- org.apache.hadoop.io.compress系列1-认识解码器/编码器
- FTP-org.apache.commons.net.io.CopyStreamException: IOException caught while copying.
- maven:java.lang.NoClassDefFoundError: org/apache/commons/io/Charsets
- java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream
- 文件上传(附加org.apache.commons.io方法使用)
- org.apache.commons.io.FileUtils的使用
- apache-comnons系列之commons-chain1.2 学习笔记
- org.apache.commons.io.FileUtils 文件处理相关
- java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
- 利用org.apache.commons.io.FileUtils快速读写文件
- Struts2框架入门案例时的异常——java.lang.NoClassDefFoundError- org-apache-commons-io-FileUtils
- apache-comnons系列之commons-compress1.14 学习笔记
- apache-comnons系列之commons-email1.4 学习笔记
- ClassNotFoundException:org.apache.commons.io.output.DeferredFileOutputStream error while using commo
- 报错:maven:java.lang.NoClassDefFoundError: org/apache/commons/io/Charsets