Utility calls

Java is very verbose. Therefore many people have come up with calls to do very common things. For example:

java.util.Arrays.toString(array);
java.util.Arrays.deepToString(nestedArray);

This prints the contents of the array, instead of a cryptic string. This method is available since 1.5.

Another good one is:

org.apache.commons.io.IOUtils.closeQuietly(stream);

Usually used in a finally clause, this one closes streams or readers, ignore IOExceptions, and handles null. This is available in the Apache commons-io library.

RSS feed for comments on this post · TrackBack URL

Leave a Comment