* Implement new toCharArray(String) method.

This commit is contained in:
hns 2007-03-16 23:18:06 +00:00
parent 3020e80650
commit 159251911d

View file

@ -57,4 +57,15 @@ public class StringUtils {
return str.split("\\r\\n|\\r|\\n"); return str.split("\\r\\n|\\r|\\n");
} }
/**
* Get the character array for a string. Useful for use from
* Rhino, where the Java String methods are not readily available
* without constructing a new String instance.
* @param str a string
* @return the char array
*/
public static char[] toCharArray(String str) {
return str == null ? new char[0] : str.toCharArray();
}
} }