Skip to content

Common Java utility methods every programmer should use (Part 1)

This post will be the first in a series of posts describing useful utility methods that will help make any programmers day to day code implementation easier.

The methods in this post:

    String.format()
    java.io.FileFilter
    Collections.sort()
    parsePropertiesFromString()

String.format()
This method is useful to build a string programmatically without using concatenation, it generally makes for more readable and therefore manageable code.

Collections.sort()
A straight forward method call used to sort a collection based on its “natural order” – alphabetically for Strings, numerically for Integers.

java.io.FileFilter
This class enables you to specify how you want to filter files that you add to a Collection.

CollectionStringUtils.parsePropertiesFromString()
This handy method is from the impala framework: org.impalaframework, and allows you to create a Map of key value pairs from a String object.

Published inJavaProgramming

2 Comments

    • crm crm

      Yup, have been using both StringUtils and guava a lot also. Expect some posts on both soon enough, time permitting.

Leave a Reply

Your email address will not be published. Required fields are marked *