Beautify Java code help

I really wish I can beautify my clipboard of java code using something like this tool : http://www.tutorialspoint.com/online_java_formatter.htm

I have some java code in my clipboard, I press a hotkey or some trigger, and my clipboard changes to beatify this code. If I can figure out how to do it for java, I can do it for other languages too.

Can I do this? Thank you for any help.

Probably the kind of thing I would do with a code editor, like Atom, but if you install node.js, the npm repository should contain beautifiers which you can call from a shell script action in KM