Java Beautifiers
Sun recommends Code Conventions for the JavaTM Programming Language, they aid in the readability of the software, allowing engineers to understand new code more quickly and thoroughly. A more detailed document can be found on the Sun Site on Code Conventions.
A lot of freeware beautifiers are found on the web. The one I use is JPretty. It is very simple to use.
Install it. Create a project under which you want to add java files. Add the files you want to beautify. Check the Beautify settings on indentation of statements, spaces between local variable and its type etc. And hit Beautify.The difference in layout is something like the following,
Before Beautify:
class SayHello {
private
String Hello = "Hello: ";
// Maximum printable size
static final
int MAXPRINT = 5;
public void say(String name, int val)
throws Exception {
for(int i = 0; i < val; i++)
if(i < MAXPRINT)
System.out.println(Hello + name);
else throw new Exception();
}
public static void main(String args[]) {
try {
new SayHello().say(args[0],
Integer.parseInt(args[1]));
} catch(Exception e) { System.out.println(e); }}
}After Beautify:
class SayHello
{
public void say(String name, int val) throws Exception {
for(int i = 0;i < val;i++)
if(i < MAXPRINT)
System.out.println(Hello + name);
else
throw new Exception();
}
public static void main(String args[]) {
try {
new SayHello().say(args[0],Integer.parseInt(args[1]));
}
catch(Exception e) {
System.out.println(e);
}
}
// Maximum printable size
static final int MAXPRINT = 5;
private String Hello = "Hello: ";
}