Some useful java snippets