Some useful Java snippets