你好,游客 登录 注册 搜索
背景:
阅读新闻

Apache Commons IO 2.3 发布

[日期:2012-04-16] 来源:Linux社区  作者:Linux [字体:大 中 小]

Apache Commons IO 2.3 带来如下新功能:

o IO-318:  Add Charset sister APIs to method that take a String charset name. Thanks to ggregory.
o IO-321:  ByteOrderMark UTF_32LE is incorrect. Thanks to ggregory.
o IO-322:  Add and use class Charsets. Thanks to ggregory.

Commons项目中用来处理IO的一些工具类包,下面是一些示例代码:

//直接将IO流转成字符串
InputStream in = new URL( "http://jakarta.apache.org" ).openStream();
try {
System.out.println( IOUtils.toString( in ) );
} finally {
IOUtils.closeQuietly(in);
}
//读取文本文件的所有行
File file = new File("/commons/io/project.properties");
List lines = FileUtils.readLines(file, "UTF-8");
//路径处理
String filename = "C:/commons/io/../lang/project.xml";
String normalized = FilenameUtils.normalize(filename);
// result is "C:/commons/lang/project.xml"
//获取目录空间
long freeSpace = FileSystemUtils.freeSpace("C:/");
//打印文件的所有行
LineIterator it = FileUtils.lineIterator(file, "UTF-8");
try {
while (it.hasNext()) {
String line = it.nextLine();
/// do something with line
}
} finally {
LineIterator.closeQuietly(iterator);
}

Commons-IO下载地址请点这里

linux
相关资讯       Commons 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款