Various utility functions in Java