public static String join(Object array[], String separator)
{
if(array == null)
return null;
if(separator == null)
separator = "";
int arraySize = array.length;
int bufSize = arraySize != 0 ? arraySize * ((array[0] != null ? array[0].toString().length() : 16) + (separator == null ? 0 : separator.length())) : 0;
StringBuffer buf = new StringBuffer(bufSize);
for(int i = 0; i < arraySize; i++)
{
if(separator != null && i > 0)
buf.append(separator);
if(array[i] != null)
buf.append(array[i]);
}
return buf.toString();
}
posted on 2011-12-21 10:01
紫蝶∏飛揚↗ 阅读(837)
评论(0) 编辑 收藏 所属分类:
JAVA