Wednesday, August 27, 2008

Don't forget about StringUtil!

StringUtil is yet another great useful utility class that does some nice work for you if used correctly.

Here some examples:

List myList
= StringUtil.detokenizeStringAsList("ABC, DEF, AVC, EWR, ASD" , ",", true);

This gives you a nice list of all the items in the given string and does a trim() on them.


Here the API info:

detokenizeStringAsList
public static java.util.List detokenizeStringAsList(java.lang.String input,
java.lang.String separator,
boolean trimsItems)

Given an input String and a separator String, this method returns a String List of tokens based on tokenizing with the String separator.

Parameters:input - String
separator - String
trimsItems - whether each item will be trimmed
Returns:
String array of tokens


Yes there is more then that, check out the API docs for more details: com.workbrain.util.StringUtil

Some versions ago the changed the name of the class
   StringHelper -> StringUtil

No comments: