diff --git a/src/helma/util/StringUtils.java b/src/helma/util/StringUtils.java index 36a05dde..831741d3 100644 --- a/src/helma/util/StringUtils.java +++ b/src/helma/util/StringUtils.java @@ -57,4 +57,15 @@ public class StringUtils { 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(); + } + }