Apache Commons IO组件介绍使用
2017-09-05 11:32
369 查看
Apache Commons IO组件介绍使用
介绍
java io操作是开发中比较常用的技术,但是如果每次都使用原生的IO流来操作那么会显得很不比较繁琐, 因此我们可以借助apache commons io包下工具类来帮我们实现一些常用的操作。 比如:拷贝、将流转为字符串等常用功能 备注:apache commons io包里的代码其实并不复杂,我们可以看看它的源码研究下人家是怎么写的,可以参考一下。
核心工具类
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 stream
write - these methods write data to a stream
copy - these methods copy all the data from one stream to another
contentEquals - 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
总结
使用commons io可以提供我们更便捷的基本操作流方式,我们应该去看下它的实现源码,虽然比较简单但是也值得参考。 复杂情况下还是需要我们自己写。
Apache Commons下都是些日常开发会用到的一些组件,我们应该好好研究一下,起码对初中级的程序员还是很有帮助的
组件 | 功能介绍 |
---|---|
BeanUtils | 提供了对于JavaBean进行各种操作,克隆对象,属性等等 |
Codec | 处理常用的编码方法的工具类包 例如DES、SHA1、MD5、Base64等. |
Collections | java集合框架操作 |
DBCP | 提供数据库连接池服务. |
DbUtils | 提供对jdbc 的操作封装来简化数据查询和记录读取操作. |
java发送邮件 对javamail的封装. | |
FileUpload | 提供文件上传功能. |
HttpClien | 提供HTTP客户端与服务器的各种通讯操作. 现在已改成HttpComponents |
IO | io工具的封装 |
Lang | Java基本对象方法的工具类包 如:StringUtils,ArrayUtils等等 |
Logging | 提供的是一个Java 的日志接口. |
Validator | 提供了客户端和服务器端的数据验证框架. |
参考
1、http://commons.apache.org/proper/commons-io/
相关文章推荐
- Apache Commons IO组件介绍使用
- Apache Commons Email组件介绍使用
- Apache Commons Codec组件介绍使用
- Apache Commons Collections组件介绍使用
- 使用Apache Commons IO组件读取大文件
- 简单介绍下我使用了一年多还不知道的Sql server 2005 组件知识
- Apache Commons 工具类介绍及简单使用
- 四大组件之一 --Services介绍和使用
- Android Design Support Library 中控件的使用简单介绍(一)介绍 在这个 Lib 中主要包含了 8 个新的 material design 组件!最低支持 Android
- 使用apache commons-io的FileUtils.copyFile简单地复制文件
- asp.net中Fine Uploader文件上传组件使用介绍
- Apache Commons 工具类介绍及简单使用
- java日志组件logback、slf4j的介绍及配置使用方法(一)
- React-Native之轮播组件looped-carousel的介绍与使用
- Apache Commons 工具类介绍及简单使用
- 树形组件ExpandableListView的使用介绍
- ExtJs4组件中initComponent方法介绍以及为什么要使用this.callParent();
- 使用Apache的commons-fileupload和commmons-io组件实现文件上传
- [置顶] Android架构组件ViewModel和LiveData介绍及使用
- Vue单文件组件的如何使用方式介绍