Converted formatter.py to Java. The Java file *might* not work flawlessly yet.

The tests I have run seemed fine, the code itself is a lot messier though.
Also processes small changes to formatter.py itself.