代码如下:
//连接字符串
//www.jb200.com
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();
}