- 浏览: 1396826 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (328)
- JSF (27)
- 生活 (12)
- Ajax (26)
- Maven (6)
- CSS (1)
- Shale (3)
- SiteMesh (1)
- Ext (15)
- JMX (2)
- Windows技巧 (7)
- 工作感悟 (18)
- SVN (2)
- SVG (0)
- GoogleGear (0)
- RAP (2)
- SOA与WebService (3)
- 笔记本技术研究 (1)
- Microsoft (2)
- 英语学习 (3)
- PHP (7)
- web 2.0 (6)
- 语义Web (1)
- IT史话 (3)
- iText (3)
- JVM (1)
- PropertiesEditor (1)
- J2SE (33)
- Spring (2)
- Java Batch (1)
- log (2)
- Struts2 (2)
- DWR (0)
- JAAS (3)
- EJB3 (4)
- Flex (8)
- JFreeChart (1)
- WAS (0)
- 数据库 (2)
- 摄影 (0)
- SQL (1)
- Google App Engine (1)
- linux (5)
- Eclipse plugin (10)
- Testing (0)
- Portal (0)
- 移动互联网 (0)
- SWTBot (1)
最新评论
-
江奇缘:
不错!!!!!!
web.xml里<filter-mapping>中的<dispatcher>作用 -
yy8093:
commonj 第三步,那个调用的方法要在哪里调?servle ...
JAVA中多种计时器的比较与分析 -
di1984HIT:
学习了,不错~
web.xml里<filter-mapping>中的<dispatcher>作用 -
penkee:
com.lowagie.text.DocumentExcept ...
iText中输出 中文 -
氵壞男亼乀:
我想请问下 你哪个html里面引入的几个js文件没看懂!你 ...
DWR入门教程之HelloWorld
Apache 里面包含了太多有用的项目,值得我们仔细研究。恰当的应用这些工具,能有效提高我们的开发效率,下面我们先来看一下io吧,觉得平常用apache的io 以及file 工具类已经很多了,但是没想到今天看了一下,还是有一些没有用过,汗一个。
IOUtils contains utility methods dealing with reading, writing and copying. The methods work on InputStream, OutputStream, Reader and Writer. As an example, consider the task of reading bytes from a URL, and printing them. This would typically done like this: With the IOUtils class, that could be done with: In certain application domains, such IO operations are common, and this class can save a great deal of time. And you can rely on well-tested code. For utility code such as this, flexibility and speed are of primary importance. However you should also understand the limitations of this approach. Using the above technique to read a 1GB file would result in an attempt to create a 1GB String object! The FileUtils class contains utility methods for working with File objects. These include reading, writing, copying and comparing files. For example to read an entire file line by line you could use: The FilenameUtils class contains utility methods for working with filenames without using File objects. The class aims to be consistent between Unix and Windows, to aid transitions between these environments (such as moving from development to production). For example to normalize a filename removing double dot segments: The FileSystemUtils class contains utility methods for working with the file system to access functionality not supported by the JDK. Currently, the only method is to get the free space on a drive. Note that this uses the command line, not native code. For example to find the free space on a drive: Different computer architectures adopt different conventions for byte ordering. In so-called "Little Endian" architectures (eg Intel), the low-order byte is stored in memory at the lowest address, and subsequent bytes at higher addresses. For "Big Endian" architectures (eg Motorola), the situation is reversed. There are two classes in this package of relevance: For more information, see http://www.cs.umass.edu/~verts/cs32/endian.html The The See the filefilter package javadoc for more details. The See the comparator package javadoc for more details. The Utility classes
IOUtils
InputStream in = new URL( "http://jakarta.apache.org" ).openStream();
try {
InputStreamReader inR = new InputStreamReader( in );
BufferedReader buf = new BufferedReader( inR );
String line;
while ( ( line = buf.readLine() ) != null ) {
System.out.println( line );
}
} finally {
in.close();
}
InputStream in = new URL( "http://jakarta.apache.org" ).openStream();
try {
System.out.println( IOUtils.toString( in ) );
} finally {
IOUtils.closeQuietly(in);
}
FileUtils
File file = new File("/commons/io/project.properties");
List lines = FileUtils.readLines(file, "UTF-8");
FilenameUtils
String filename = "C:/commons/io/../lang/project.xml";
String normalized = FilenameUtils.normalize(filename);
// result is "C:/commons/lang/project.xml"
FileSystemUtils
long freeSpace = FileSystemUtils.freeSpace("C:/");
Endian classes
DataInput
interface. With this, one can read data from files of non-native Endian-ness.
Line iterator
org.apache.commons.io.LineIterator
class provides a flexible way for working with a line-based file. An instance can be created directly, or via factory methods onFileUtils
or IOUtils
. The recommended usage pattern is: LineIterator it = FileUtils.lineIterator(file, "UTF-8");
try {
while (it.hasNext()) {
String line = it.nextLine();
/// do something with line
}
} finally {
LineIterator.closeQuietly(iterator);
}
File filters
org.apache.commons.io.filefilter
package defines an interface (IOFileFilter ) that combines both java.io.FileFilter
and java.io.FilenameFilter
. Besides that the package offers a series of ready-to-use implementations of the IOFileFilter
interface including implementation that allow you to combine other such filters. These filters can be used to list files or in FileDialog, for example.
File comparators
org.apache.commons.io.comparator
package provides a number of java.util.Comparator
implementations for java.io.File
. These comparators can be used to sort lists and arrays of files, for example.
Streams
org.apache.commons.io.input
and org.apache.commons.io.output
packages contain various useful implementations of streams. These include:
发表评论
-
百万级访问量网站的技术准备工作
2010-12-29 19:35 1466当今从纯网站技术上来说,因为开源模式的发展,现在建一个小 ... -
Java EE Productivity Report 2011
2010-12-21 17:02 1638What happens when over 1000 J ... -
java.util.prefs.Preferences 简介
2010-04-23 14:07 4478Version 0.2 Cop ... -
An Introduction to LDAP
2010-04-13 16:24 1050An Introduction to LDAP Mich ... -
Java Interface 是常量存放的最佳地点吗?
2009-08-21 18:21 1263由于java interface中声明 ... -
Java的内存泄漏
2009-08-20 22:50 1295Java是如何管理内存 为了判断Java中是否有内 ... -
Transform XML into HTML using XSLT
2009-08-20 12:14 1834[howto.xml] <?xml versio ... -
eclipse 无法启动 JVM terminated. Exit code=-1
2009-08-09 13:52 2471eclipse 无法启动 JVM terminated. ... -
SDO ,WorkMananger,CommonJ overview
2009-07-06 10:51 1309Service Data Objects (SDO) -- P ... -
JAVA中多种计时器的比较与分析
2009-07-06 10:34 24099介绍 计时器可以提供运行基于时间的工作任务的功能,在计时器的管 ... -
Hashtable和HashMap的区别 Vector、ArrayList和List的异同(笔记)
2009-07-04 08:10 1907Hashtable和HashMap的区别:1.Hashtabl ... -
Java: System Properties
2009-05-25 11:10 2049From System Properties you ca ... -
SSL证书转换
2009-05-18 17:33 8521PKCS 全称是 Public-Key Cryptogra ... -
Keystores and Truststores
2009-05-18 14:39 2663Keystores and Truststores ... -
google app engine 是什么?
2009-04-08 18:50 3247Google是个真正能不断的 ... -
如何输入版权符号 copyright
2009-04-08 13:21 12293Unicode Character 'COPYRIGH ... -
深入浅出URL编码
2009-04-05 13:31 1125版权声明:如有转载请 ... -
Java IO一览
2009-04-04 12:23 1682对于我们常用的GBK中,英文是占用1个字节,中文是2个 对于 ... -
字节流与字符流的区别
2009-04-04 12:13 15103最近在项目中遇到一个encoding的问题,记录一下。 ... -
深入了解Unicode
2009-04-02 00:31 1713Unicode (统一码 、万国 ...
相关推荐
### Java IO 教程概述:理解输入与输出 在深入探讨Java IO(输入输出)教程之前,我们首先需要澄清一个常见的概念混淆:“输入”与“输出”。这两个术语在不同的上下文中可能让人感到迷惑,尤其是在软件工程领域。...
在Struts2框架中,Apache Commons IO是一个关键的类库,它提供了大量的实用工具类来处理输入/输出操作。这个文档包"commons-io-1.3.2"是针对该版本的API详细参考,对开发者来说是非常有价值的资源。 Apache Commons...
西门子S7-300中高级应用技术
Overview Understand Apache Karaf's commands and control capabilities Gain familiarity with its provisioning features Explore various application deployments targets experientially ☆ 出版信息:☆ ...
Handling or Historical DataAccess) and a specification for interfaces that are common for all OPC Servers are available as separate documents. Chapter 1 gives some background information. It ...
基础篇-Linux IO stack overview 基础篇-read syscall IO stack 工具篇-iostat数据可靠吗 工具篇-blktrace原理和应用 工具篇-debugfs应用 Cache server机械盘IO性能瓶颈分析 实践篇-IO性能优化之文件压缩 实践篇-IO...
Overview Understand Apache Karaf’s commands and control capabilities Gain familiarity with its provisioning features Explore various application deployments targets experientially In Detail Apache ...
It introduces the two most common methods for MTL in Deep Learning, gives an overview of the literature, and discusses recent advances. In particular, it seeks to help ML practitioners apply MTL ...
标题中的"overview_20200306_V4_overview_氛围灯_vbaexcel_"暗示了这是一个关于2020年3月6日版本的车内氛围灯系统概述,利用VBA(Visual Basic for Applications)和Excel进行自动化管理的项目。这个系统可能是为了...
Xiao Li and Wenchen Fan offer an overview of the major features and enhancements in Apache Spark 2.4. Along the way, you’ll learn about the design and implementation of V2 of theData Source API and ...
"SAP 中文版Overview" 在这个 SAP 中文版Overview 中,我们将详细介绍 SAP 的概念、结构、模块、导航和业务流程等知识点。 MRP、MRPII 和 ERP 的概念 MRP(Material Requirements Planning,物料需求规划)是根据...
eclipse overview插件 跟sublime 的预览插件一样效果 由于无法在线安装,可以使用link方式安装 步骤如下 1、下载好解压文件,解压到指定目录如: D:\Program Files (x86)\eclipse\overview目录 2、找到eclipse安装...
SAP SD overview SAP SD overview SAP SD overview SAP SD overview
Overview Integrate Flume with your data sources Transcode your data en-route in Flume Route and separate your data using regular expression matching Configure failover paths and load-balancing to ...
openEHR Overview openEHR的概要介绍
The book begins with an overview of big data and Apache Hadoop. Then, you will set up a pseudo Hadoop development environment and a multi-node enterprise Hadoop cluster. You will see how the parallel ...
SAP: hr+overview.ppt