日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁(yè) > 芯聞號(hào) > 充電吧
[導(dǎo)讀] Apache Commons IO組件介紹使用 介紹 java io操作是開發(fā)中比較常用的技術(shù),但是如果每次都使用原生的IO流來操作那么會(huì)顯得很不比較繁瑣, 因此我們可以借助apache com

Apache Commons IO組件介紹使用
介紹
java io操作是開發(fā)中比較常用的技術(shù),但是如果每次都使用原生的IO流來操作那么會(huì)顯得很不比較繁瑣,
因此我們可以借助apache commons io包下工具類來幫我們實(shí)現(xiàn)一些常用的操作。

比如:拷貝、將流轉(zhuǎn)為字符串等常用功能
備注:apache commons io包里的代碼其實(shí)并不復(fù)雜,我們可以看看它的源碼研究下人家是怎么寫的,可以參考一下。

核心工具類

IOUtils類

General IO stream manipulation utilities
This class provides static utility methods for input/output operations.

All the methods in this class that read a stream are buffered internally.
This means that there is no cause to use a BufferedInputStream or BufferedReader. 
The default buffer size of 4K has been shown to be efficient in tests.

備注:IOUtils主要提供更便捷的操作流的方法    

主要方法

toXxx/read - these methods read data from a streamwrite - these methods write data to a streamcopy - these methods copy all the data from one stream to anothercontentEquals - these methods compare the content of two streams

FileUtils類

General file manipulation utilities.
Facilities are provided in the following areas
備注:主要提供方便操作文件/目錄的方法

主要方法?


writing to a file?
reading from a file?
make a directory including parent directories?
copying files and directories?
deleting files and directories?
converting to and from a URL?
listing files and directories by filter and extension?
comparing file content?
file last changed date?
calculating a checksum?


總結(jié)
使用commons io可以提供我們更便捷的基本操作流方式,我們應(yīng)該去看下它的實(shí)現(xiàn)源碼,雖然比較簡(jiǎn)單但是也值得參考。
復(fù)雜情況下還是需要我們自己寫。

Apache Commons下都是些日常開發(fā)會(huì)用到的一些組件,我們應(yīng)該好好研究一下,起碼對(duì)初中級(jí)的程序員還是很有幫助的
組件 功能介紹 BeanUtils 提供了對(duì)于JavaBean進(jìn)行各種操作,克隆對(duì)象,屬性等等 Codec 處理常用的編碼方法的工具類包 例如DES、SHA1、MD5、Base64等. Collections java集合框架操作 DBCP 提供數(shù)據(jù)庫(kù)連接池服務(wù). DbUtils 提供對(duì)jdbc 的操作封裝來簡(jiǎn)化數(shù)據(jù)查詢和記錄讀取操作. Email java發(fā)送郵件 對(duì)javamail的封裝. FileUpload 提供文件上傳功能. HttpClien 提供HTTP客戶端與服務(wù)器的各種通訊操作. 現(xiàn)在已改成HttpComponents IO io工具的封裝 Lang Java基本對(duì)象方法的工具類包 如:StringUtils,ArrayUtils等等 Logging 提供的是一個(gè)Java 的日志接口. Validator 提供了客戶端和服務(wù)器端的數(shù)據(jù)驗(yàn)證框架.
參考

1、http://commons.apache.org/proper/commons-io/



本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉