org.apache.commons.io |
This package defines utility classes for working with streams, readers,
writers and files. The most commonly used classes are described here:
IOUtils is the most frequently used class.
It provides operations to read, write, copy and close streams.
FileUtils provides operations based around the JDK File class.
These include reading, writing, copying, comparing and deleting.
FilenameUtils provides utilities based on filenames.
This utility class manipulates filenames without using File objects.
It aims to simplify the transition between Windows and Unix.
Before using this class however, you should consider whether you should
be using File objects.
FileSystemUtils allows access to the filing system in ways the JDK
does not support. At present this allows you to get the free space on a drive.
EndianUtils swaps data between Big-Endian and Little-Endian formats.
|
Java Source File Name | Type | Comment |
AllIOTestSuite.java | Class | A basic test suite that tests all the IO component. |
CopyUtils.java | Class | This class provides static utility methods for buffered
copying between sources (InputStream , Reader ,
String and byte[] ) and destinations
(OutputStream , Writer , String and
byte[] ).
Unless otherwise noted, these copy methods do not
flush or close the streams. |
CopyUtilsTest.java | Class | JUnit tests for CopyUtils. |
DemuxTestCase.java | Class | Basic unit tests for the multiplexing streams. |
DirectoryWalker.java | Class | Abstract class that walks through a directory hierarchy and provides
subclasses with convenient hooks to add specific behaviour.
This class operates with a
FileFilter and maximum depth to
limit the files and direcories visited.
Commons IO supplies many common filter implementations in the
filefilter package.
The following sections describe:
|
DirectoryWalkerTestCase.java | Class | This is used to test DirectoryWalker for correctness. |
EndianUtils.java | Class | Utility code for dealing with different endian systems.
Different computer architectures adopt different conventions for
byte ordering. |
EndianUtilsTest.java | Class | |
FileCleaner.java | Class | Keeps track of files awaiting deletion, and deletes them when an associated
marker object is reclaimed by the garbage collector.
This utility creates a background thread to handle file deletion.
Each file to be deleted is registered with a handler object.
When the handler object is garbage collected, the file is deleted.
In an environment with multiple class loaders (a servlet container, for
example), you should consider stopping the background thread if it is no
longer needed. |
FileCleanerTestCase.java | Class | This is used to test FileCleaner for correctness. |
FileCleaningTracker.java | Class | Keeps track of files awaiting deletion, and deletes them when an associated
marker object is reclaimed by the garbage collector.
This utility creates a background thread to handle file deletion.
Each file to be deleted is registered with a handler object.
When the handler object is garbage collected, the file is deleted.
In an environment with multiple class loaders (a servlet container, for
example), you should consider stopping the background thread if it is no
longer needed. |
FileCleaningTrackerTestCase.java | Class | This is used to test
FileCleaningTracker for correctness. |
FileDeleteStrategy.java | Class | Strategy for deleting files. |
FileDeleteStrategyTestCase.java | Class | Test for FileDeleteStrategy. |
FilenameUtils.java | Class | General filename and filepath manipulation utilities.
When dealing with filenames you can hit problems when moving from a Windows
based development machine to a Unix based production machine.
This class aims to help avoid those problems.
NOTE: You may be able to avoid using this class entirely simply by
using JDK
java.io.File File objects and the two argument constructor
java.io.File.File(java.io.Filejava.lang.String) File(File,String) .
Most methods on this class are designed to work the same on both Unix and Windows.
Those that don't include 'System', 'Unix' or 'Windows' in their name.
Most methods recognise both separators (forward and back), and both
sets of prefixes. |
FilenameUtilsTestCase.java | Class | This is used to test FilenameUtils for correctness. |
FilenameUtilsWildcardTestCase.java | Class | |
FileSystemUtils.java | Class | General File System utilities.
This class provides static utility methods for general file system
functions not provided via the JDK
java.io.File File class.
The current functions provided are:
- Get the free space on a drive
author: Frank W. |
FileSystemUtilsTestCase.java | Class | This is used to test FileSystemUtils. |
FileUtils.java | Class | 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
Origin of code: Excalibur, Alexandria, Commons-Utils
author: Kevin A. |
FileUtilsCleanDirectoryTestCase.java | Class | Test cases for FileUtils.cleanDirectory() method. |
FileUtilsFileNewerTestCase.java | Class | This is used to test FileUtils for correctness. |
FileUtilsListFilesTestCase.java | Class | Test cases for FileUtils.listFiles() methods. |
FileUtilsTestCase.java | Class | This is used to test FileUtils for correctness. |
FileUtilsWaitForTestCase.java | Class | This is used to test FileUtils.waitFor() method for correctness. |
HexDump.java | Class | Dumps data in hexadecimal format. |
HexDumpTest.java | Class | |
IOCase.java | Class | Enumeration of IO case sensitivity.
Different filing systems have different rules for case-sensitivity.
Windows is case-insensitive, Unix is case-sensitive.
This class captures that difference, providing an enumeration to
control how filename comparisons should be performed. |
IOCaseTestCase.java | Class | This is used to test IOCase for correctness. |
IOUtils.java | Class | General IO stream manipulation utilities.
This class provides static utility methods for input/output operations.
- closeQuietly - these methods close a stream ignoring nulls and exceptions
- 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
The byte-to-char methods and char-to-byte methods involve a conversion step.
Two methods are provided in each case, one that uses the platform default
encoding and the other which allows you to specify an encoding. |
IOUtilsCopyTestCase.java | Class | JUnit tests for IOUtils copy methods. |
IOUtilsTestCase.java | Class | This is used to test IOUtils for correctness. |
IOUtilsWriteTestCase.java | Class | JUnit tests for IOUtils write methods. |
LineIterator.java | Class | An Iterator over the lines in a Reader .
LineIterator holds a reference to an open Reader .
When you have finished with the iterator you should close the reader
to free internal resources. |
LineIteratorTestCase.java | Class | This is used to test LineIterator for correctness. |
PackageTestSuite.java | Class | A basic test suite that tests all the IO package. |