//直接将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);
}

Apache Commons IO 2.3 几点用法的更多相关文章

  1. apache.commons.io.IOUtils: 一个很方便的IO工具库(比如InputStream转String)

    转换InputStream到String, 比如 //引入apache的io包 import org.apache.commons.io.IOUtils; ... ...String str = IO ...

  2. Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils

    1.错误叙述性说明 警告: Could not create JarEntryRevision for [jar:file:/D:/MyEclipse/apache-tomcat-7.0.53/web ...

  3. apache commons io包基本功能

    1. http://jackyrong.iteye.com/blog/2153812 2. http://www.javacodegeeks.com/2014/10/apache-commons-io ...

  4. java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream(转)

    java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream 使用Tomcat的Manag ...

  5. IO与文件读写---使用Apache commons IO包提高读写效率

    觉得很不错,就转载了, 作者: Paul Lin 首先贴一段Apache commons IO官网上的介绍,来对这个著名的开源包有一个基本的了解:Commons IO is a library of ...

  6. Apache Commons IO入门教程(转)

    Apache Commons IO是Apache基金会创建并维护的Java函数库.它提供了许多类使得开发者的常见任务变得简单,同时减少重复(boiler-plate)代码,这些代码可能遍布于每个独立的 ...

  7. [转]Apache Commons IO入门教程

    Apache Commons IO是Apache基金会创建并维护的Java函数库.它提供了许多类使得开发者的常见任务变得简单,同时减少重复(boiler-plate)代码,这些代码可能遍布于每个独立的 ...

  8. java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream

    java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream at org.apach ...

  9. Apache Commons IO之FileUtils的常用方法

    Apache Commons IO 在学习io流的时候研究(翻译)了一下这个,只有FileUtils的某些方法,并不全面,还请谅解 org.apache.commons.io 这个包下定义了基于 st ...

随机推荐

  1. ADB操作多台设备

    1.adb devices 查看所有连接设备. 2.adb -s <设备名> shell 指定device来执行adb shell. 3.adb -s <设备名> <指令 ...

  2. swift 函数返回值

    函数的定义及调用 func开头作为前缀,->返回的类型 add输出结果是11 函数参数也可以有多个参数,写在括号里用逗号隔开. func introduce(name: String,age: ...

  3. Content by query webpart 自定义样式的使用方法

    今天研究一个非常实用的webpart 如果在office365 上 的webpart中一直没“内容查询”, 这里需要开启2个features:http://community.office365.co ...

  4. java新手笔记16 面积

    1.图形类 package com.yfs.javase; public class Shape { //计算面积方法 public double getArea() { System.out.pri ...

  5. UVA 10066 The Twin Towers(LCS)

    Problem B The Twin Towers Input: standard input Output: standard output Once upon a time, in an anci ...

  6. AOP学习过程中遇到的问题汇总

    jdk版本问题:     在spring较低的版本中,仅支持jdk1.5到1.7版本,由于我本机安装的是jdk1.8,所以在调试的时候就会提示jdk版本要高于1.5.于是换成spring4.0,在co ...

  7. C#中的Collections命名空间

    System.Collections命名空间包含可使用的集合类和相关的接口. 该命名空间下的.NET非泛型集合类如下所示: — System.Collections.ArrayList:数组集合类,使 ...

  8. ubuntu server 安装

    http://tigerlchen.iteye.com/blog/1765765  解决CDROM找不到的bug

  9. 思维导图软件VYM

    http://www.insilmaril.de/vym/ 点击打开链接http://www.oschina.net/p/vym 有人说VYM就跟目录是一回事,确实是这样, 只不过与excel之类的比 ...

  10. jQuery 之 .stop() 方法

    总结version 1.7版本前.stop([clearQueue][,jumpToEnd])clearQueue: 布尔值,默认是 false;此值处理是相关的动画队列是否移除,如果为 false ...