和String.split()使用最后的类Pattern进行拆分.Pattern.compile(regex).split(this , limit);StringUtils中的使用自己的方法splitWorker(String str, char separatorChar, boolean preserveAllTokens),这是针对2.0(JDK1.4)的性能调整.What is the difference between StringUtils.splitByWholeSeparatorPreserveAllTokens() and String.split()?With splitByWholeSeparatorPreserveAllTokens, we could limit the number of parameters that are returned in an array. Is this the only difference? 解决方案 java.lang.String.split();Usage:The array returned by this method contains each substring of this string that is terminated by another substring that matches the given expression or is terminated by the end of the string. The substrings in the array are in the order in which they occur in this string. If the expression does not match any part of the input then the resulting array has just one element, namely this string.org.apache.commons.lang.StringUtils.splitPreserveAllTokens();Usage:Splits the provided text into an array, separator specified, preserving all tokens, including empty tokens created by adjacent separators. This is an alternative to using StringTokenizer.Read more: kickjava_src_apache_StringUtilsand String.split() uses the final class Pattern to split.Pattern.compile(regex).split(this , limit);in StringUtils uses splitWorker(String str, char separatorChar, boolean preserveAllTokens) , it's own method, which is a Performance tune for 2.0 (JDK1.4). 这篇关于splitByWholeSeparatorPreserveAllTokens和split之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 14:35