I have many Java files from a project which have not been formatted properly. Also due to enforcement of a common style many people have introduced their own coding style. I want to bring all this code to one consistent format. Are there any auto-formatters available which I can run as script on all the files. I would like to rethink and fine tune following options:
-
Number of spaces used for indentation.
-
Spaces around operators like + – * / etc.
-
Separation between parentheses.
-
etc.
I was looking at Netbeans auto format and looked cool. Moreover the parameters can be set from the option dialog. However I am not able to completely grasp how to use the API
You can use the Eclipse
JavaCodeFormatterfrom the command line:See http://wiyoo.blogspot.com/2007/05/batch-formatting-java-source-code-with.html for details.