Added parseBooleanArray method.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@2121 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
samskivert@gmail.com
2007-07-05 19:07:13 +00:00
parent 977126b6df
commit 803940faf0
@@ -934,6 +934,23 @@ public class StringUtil
return vals;
}
/**
* Parses an array of booleans from its string representation. The array should be represented
* as a bare list of numbers separated by commas, for example:
*
* <pre>false, false, true, false</pre>
*/
public static boolean[] parseBooleanArray (String source)
{
StringTokenizer tok = new StringTokenizer(source, ",");
boolean[] vals = new boolean[tok.countTokens()];
for (int i = 0; tok.hasMoreTokens(); i++) {
// trim the whitespace from the token
vals[i] = Boolean.parseBoolean(tok.nextToken().trim());
}
return vals;
}
/**
* Parses an array of strings from a single string. The array should be represented as a bare
* list of strings separated by commas, for example: