Various useful Java snippets