commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Armstrong <>
Subject [PATCH]Commons IO New Functionality, Minor Patches
Date Wed, 28 Oct 2009 03:42:17 GMT
Hello Commons IO Developers,

Attached is a gzipped tar file that includes new functionality for
Commons IO that I hope you will consider.

The new functionality is a class that copies files, called FileCopier
and some helper classes. This class goes beyond the functionality of
the static methods included in the FileUtils class. It has the
following functionality:

It uses an extension to an abstract class, FileCopyHelper.
FileCopyHelper provides callback methods to FileCopier's copy methods.
Extensions to FileCopyHelper provide methods to define behavior for
handling destination files that exist, handling exceptions, reporting
the status of copy operations, and enables clients to cancel copies
after they have begun.
There are several extensions to FileCopyHelper that I have created.
FileCopyHelper and all of its extensions are included in a new
package, to avoid cluttering up
FileCopier uses a default FileCopyHelper extension,
SafeFileCopyHelper. This extension skips all destination files that
already exist. OverwriteFileCopyHelper overwrites all files that
exist. RenameAppendFileCopyHelper appends text to the names of all
files that exist. RenameAppendTimestampFileCopyHelper appends the
existing file's last modified date to its name. There are a few other
FileCopyHelper extensions included, also. All of the FileCopyHelper
extensions that I created print the status of copy operations and
report exceptions to standard out.

FileCopyHelper also allows clients to send a cancel request to
FileCopier to cancel subsequent copy operations. FIleCopier will throw
a runtime exception, FileCopyCancelException, when it receives a
request to cancel copy operations.

When copying directories, FileCopier gives clients the ability to
"flatten" directories if they so choose. They can flatten by directory
level or by name, using an IOFileFilter. Flattening means the
directory itself is not copied; only its contents are copied. It
likewise gives clients the ability to "merge" directories that exist.
They can merge directories by level or by name, using an IOFileFilter.
Merge is applicable when FileCopier is using a FileCopyHelper object
that renames destination files that already exist. If a directory is
to be merged, it means that the directory is not renamed. The contents
of the source directory are merged with the contents of the already
existing destination directory. Destination directories that are not
to be merged are renamed. FileCopier's default behavior is to not
merge or flatten any directories.

FileCopier is immutable and uses an inner Builder class to create
instances of it.

Included is a FileCopierTestCase class and all of its tests pass.

I tried to include javadocs in the gzipped tar file, but it made the file too
large to send. If you generate javadocs, it should create them for the
classes I introduced. Hopefully, they will answer any questions about the
functionality that I did not address here. I can send the javadocs in a
separate email if you like.

The patches I included are pretty minor. For, I changed
the access for doCopyFile() from private to protected so that
FileCopier could make use of its functionality. For, I
replaced the multiple closeQuietly() methods with one closeQuietly()
method that takes an object that implements Closeable as its argument.
If these patches are not acceptable, please let me know.

Please let me know what you think of the new functionality and any
suggestions for improvement that you have. If there is anything that I
added that you would like me to implement differently, please let me
know. I hope that you will agree that FileCopier will provide added
value to the Commons IO suite of services.

Best Regards,
David Armstrong

View raw message