Beruflich Dokumente
Kultur Dokumente
http://commons.apache.org/proper/commons-io/description.html
Apache Commons IO
Last Published: 17 February 2014 | Version: 2.5-SNAPSHOT
ApacheCon
Apache
Commons
Overview
User guide
Download
User guide
Best practices
implementations.
COMMONS IO
Javadoc 2.4
Javadoc 2.2
Javadoc 1.4
DEVELOPMENT
Building
Mailing lists
Issue Tracking
Team
Tasks
Utility classes
IOUtils
IOUtils contains utility methods dealing with reading, writing
and copying. The methods work on InputStream,
OutputStream, Reader and Writer.
Proposal
SVN repository
Javadoc (latest SVN)
PROJECT DOCUMENTATION
Project Information
Project Reports
COMMONS
Home
License
Components
Sandbox
Dormant
GENERAL INFORMATION
1 of 5
02/12/14 4:20 pm
Volunteering
http://commons.apache.org/proper/commons-io/description.html
} ffiinnaallllyy {
iinn.close();
Contributing Patches
Building Components
Releasing Components
Wiki
ASF
Developer Resources
Sponsorship
Thanks
FileUtils
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:
FilenameUtils
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
2 of 5
02/12/14 4:20 pm
http://commons.apache.org/proper/commons-io/description.html
development to production).
For example to normalize a filename removing double dot
segments:
// result is "C:/commons/lang/project.xml"
FileSystemUtils
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:
Endian classes
Dierent computer architectures adopt dierent 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:
The EndianUtils class contains static methods for
swapping the Endian-ness of Java primitives and
streams.
The SwappedDataInputStream class is an implementation
of the DataInput interface. With this, one can read
data from files of non-native Endian-ness.
For more information, see http://www.cs.umass.edu/~verts
/cs32/endian.html
Line iterator
3 of 5
02/12/14 4:20 pm
http://commons.apache.org/proper/commons-io/description.html
LLiinneeIItteerraattoorr it = FFiilleeUUttiillss.lineIterator(fil
e, "UTF-8");
ttrryy {
wwhhiillee (it.hasNext()) {
SSttrriinngg line = it.nextLine();
File filters
The org.apache.commons.io.filefilter package
defines an interface (IOFileFilter) that combines both
java.io.FileFilter and
java.io.FilenameFilter . Besides that the package
oers 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.
See the filefilter package javadoc for more details.
File comparators
The 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.
See the comparator package javadoc for more details.
Streams
The org.apache.commons.io.input and
org.apache.commons.io.output packages contain
various useful implementations of streams. These include:
4 of 5
02/12/14 4:20 pm
http://commons.apache.org/proper/commons-io/description.html
5 of 5
02/12/14 4:20 pm