##經常使用類庫 [TOC] ###IO工具類org.apache.commons.io.IOUtils
spring
####closeQuietly ( )
無條件的關閉Closeable
InputStream
OutputStream
Reader
Selector
ServerSocket
Socket
Writer
。apache
####toString ( )
將byte[]
InputStream
Reader
URI
URL
資源內容轉爲字符串api
####copy ( )
app
copy(InputStream input, OutputStream output) copy(InputStream input, Writer output, Charset inputEncoding) copy(Reader input, OutputStream output, Charset outputEncoding) //會調用flush copy(Reader input, Writer output) copyLarge //大於2GB
####toByteArray ( )
將 InputStream
Reader
String
URI
URL
資源內容轉爲byte[]
工具
####write ( )
ui
void write(byte[] data, OutputStream output) //將data寫入OutPutStream void write(char[] data, Writer output) void write(CharSequence data, Writer output) writeChunked //using chunked writes. //lineEnding默認null void writeLines(Collection<?> lines, String lineEnding, OutputStream output, Charset encoding)
####toInputStream ( )
將 CharSequence
轉爲InputStream
url
####readLines ( )
static List<String> readLines(InputStream input, Charset encoding)code
static List<String> readLines(Reader input)
####lineIterator ( )
static LineIterator lineIterator(InputStream input, Charset encoding)orm
static LineIterator lineIterator(Reader reader)
####readFully ( )
讀取指定數量的字節,若是不夠則返回失敗遞歸
###文件操做工具類org.apache.commons.io.FileUtils
####deleteDirectory ( )
遞歸的刪除一個目錄 ####readFileToString ( )
####deleteQuietly ( )
刪除文件及子目錄文件,不拋出異常,刪除目標能夠爲空
####copyFile ( )
copyDirectoryToDirectory //複製文件夾到另外一個文件夾下,保留文件日期 copyFile //複製文件,保留日期可選,或copy到OutoutStream copyFileToDirectory //複製文件保留文件日期可選 copyInputStreamToFile copyToFile //和copyInputStreamToFile同樣 copyURLToFile //保存url資源到目標文件
####writeStringToFile ( )
####forceMkdir ( )
建立目錄 ####write ( )
write(File file, CharSequence data, Charset encoding) //文件不存在則建立 static void write(File file, CharSequence data, Charset encoding, boolean append)//是否追加寫 static void writeByteArrayToFile(File file, byte[] data) static void writeLines(File file, Collection<?> lines) ####listFiles ( )
static Collection<File> listFiles(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) //Finds files within a given directory (and optionally its subdirectories).
static Collection<File> listFiles(File directory, String[] extensions, boolean recursive) //Finds files within a given directory (and optionally its subdirectories) which match an array of extensions. static Collection<File> listFilesAndDirs(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) //Finds files within a given directory (and optionally its subdirectories).
####copyDirectory ( )
static void copyDirectory(File srcDir, File destDir) //Copies a whole directory to a new location preserving the file dates. static void copyDirectory(File srcDir, File destDir, boolean preserveFileDate) //Copies a whole directory to a new location. static void copyDirectory(File srcDir, File destDir, FileFilter filter) //Copies a filtered directory to a new location preserving the file dates. static void copyDirectory(File srcDir, File destDir, FileFilter filter, boolean preserveFileDate) //Copies a filtered directory to a new location. static void copyDirectoryToDirectory(File srcDir, File destDir) //Copies a directory to within another directory preserving the file dates. ####forceDelete ( )
static void forceDelete(File file) //Deletes a file. static void forceDeleteOnExit(File file) //Schedules a file to be deleted when JVM exits.
###字符串工具類org.apache.commons.lang3.StringUtils
isBlank ( ) isNotBlank ( ) isEmpty ( ) isNotEmpty ( ) join ( ) equals ( ) split ( ) EMPTY replace ( ) capitalize ( )
toString ( ) consume ( ) toByteArray ( ) consumeQuietly ( ) getContentCharSet ( )
getExtension ( ) getBaseName ( ) getName ( ) concat ( ) removeExtension ( ) normalize ( ) wildcardMatch ( ) separatorsToUnix ( ) getFullPath ( ) isExtension ( )
hasText ( ) hasLength ( ) isEmpty ( ) commaDelimitedListToStringArray ( ) collectionToDelimitedString ( ) replace ( ) delimitedListToStringArray ( ) uncapitalize ( ) collectionToCommaDelimitedString ( ) tokenizeToStringArray ( )
contains ( ) addAll ( ) clone ( ) isEmpty ( ) add ( ) EMPTY_BYTE_ARRAY subarray ( ) indexOf ( ) isEquals ( ) toObject ( )
###org.apache.commons.lang.StringEscapeUtils
escapeHtml ( ) unescapeHtml ( ) escapeXml ( ) escapeSql ( ) unescapeJava ( ) escapeJava ( ) escapeJavaScript ( ) unescapeXml ( ) unescapeJavaScript ( )
###org.apache.http.client.utils.URLEncodedUtils
format ( ) parse ( )
md5Hex ( ) shaHex ( ) sha256Hex ( ) sha1Hex ( ) sha ( ) md5 ( ) sha512Hex ( ) sha1 ( )
###org.apache.commons.collections.CollectionUtils
isEmpty ( ) isNotEmpty ( ) select ( ) transform ( ) filter ( ) find ( ) collect ( ) forAllDo ( ) addAll ( ) isEqualCollection ( )
###org.apache.commons.lang3.ArrayUtils
contains ( ) isEmpty ( ) isNotEmpty ( ) add ( ) clone ( ) addAll ( ) subarray ( ) indexOf ( ) EMPTY_OBJECT_ARRAY EMPTY_STRING_ARRAY
getProperty ( ) setProperty ( ) getPropertyDescriptors ( ) isReadable ( ) copyProperties ( ) getPropertyDescriptor ( ) getSimpleProperty ( ) isWriteable ( ) setSimpleProperty ( ) getPropertyType ( )
###org.apache.commons.lang3.StringEscapeUtils
unescapeHtml4 ( ) escapeHtml4 ( ) escapeXml ( ) unescapeXml ( ) escapeJava ( ) escapeEcmaScript ( ) unescapeJava ( ) escapeJson ( ) escapeXml10 ( )
###org.apache.commons.beanutils.BeanUtils
copyProperties ( ) getProperty ( ) setProperty ( ) describe ( ) populate ( ) copyProperty ( ) cloneBean ( )