Artistic Style Code Reformatter Works Well
Artistic Style (http://astyle.sourceforge.net/) is a code reformatter (aka pretty
printer, code beautifier) that transforms Java code (and code in
several other languages too) into the format of your choice. It works
as advertised, is quick, easy to use, and has great defaults.
In particular, I recommend this usage:
astyle --style=java --indent=spaces=2 *.java
or, to operate on all files in all subdirectories:
astyle --style=java --indent=spaces=2 `find \*.java`
I have found it to be fast. It requires just a few seconds to operate
on hundreds of files.
It is reliable. On a large codebase, a full recompile after running it
showed no problems. It changed the formatting and indentation without
corrupting anything or introducing syntax changes.
Best of all, the default Java style matches the Sun Coding Conventions, so you are left with standard code that
you can share with any Java developer and have it easily understood.
Try out Artistic Style (http://astyle.sourceforge.net/) today. I am very happy with it
and I think you will be too.