码迷,mamicode.com
首页 > 其他好文 > 详细

从源码分析StringUtils包

时间:2017-03-06 19:44:26      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:ati   commons   tar   imp   nbsp   code   get   ons   sdn   

今天用到StringUtils.join方法,闲来无聊,看了下源码

 

当然不可能自己分析,你傻啊,在这里推荐一个别人分析的;

http://blog.csdn.net/baidu_31071595/article/details/51320622

 

首先导包

import org.apache.commons.lang3.StringUtils;

我在这里调用的是StringUtils.join方法

public static String join(Object[] array, char separator)

把数组中的元素连接成一个字符串返回,把分隔符separator也加上。

举例(*表示任意):

StringUtils.join(null, *)                        = null

StringUtils.join({}, *)                          = ""

StringUtils.join({null}, *)                      = ""

StringUtils.join({"as","df","gh","jk"}, ))     = "as df gh jk"

StringUtils.join({"as","df","gh","jk"},.))     = "as.df.gh.jk"

StringUtils.join({"as","","df","gh"},.))       = "as..df.gh"

StringUtils.join({"","as","","","df","",""},,))= ",as,,,df,,"

StringUtils.join({"","as","","","df","",""}, ))= " as   df "

StringUtils.join({"as.df.gh"},.))                 = "as.df.gh"

StringUtils.join({"as.df.gh"}, ))              = "as.df.gh"

 

 

 

 

over...

从源码分析StringUtils包

标签:ati   commons   tar   imp   nbsp   code   get   ons   sdn   

原文地址:http://www.cnblogs.com/chenzeyong/p/6511452.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!