Misc Java snippets