* Implement new toCharArray(String) method.
This commit is contained in:
parent
3020e80650
commit
159251911d
1 changed files with 11 additions and 0 deletions
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue