Implemented the native CharSequence version of toCharArray

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1089724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2011-04-07 04:03:55 +00:00
parent d1b24a3fea
commit cc3b4d31bc
1 changed files with 6 additions and 2 deletions

View File

@ -6489,8 +6489,12 @@ public class StringUtils {
if (cs instanceof String) {
return ((String) cs).toCharArray();
} else {
// TODO: Implement rather than convert to String
return cs.toString().toCharArray();
int sz = cs.length();
char[] array = new char[cs.length()];
for (int i=0; i < sz; i++) {
array[i] = cs.charAt(i);
}
return array;
}
}