教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Jsp  >  正文 jsp连接字符串的代码(不错)

jsp连接字符串的代码(不错)

发布时间:2015-09-24   编辑:jiaochengji.com
本文介绍下,jsp实现的一个连接字符串的代码,写的不错,值的参考。有需要的朋友,可以借鉴下。

代码如下:
 

复制代码 代码示例:

//连接字符串
//www.jiaochengji.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();
    }

您可能感兴趣的文章:
jsp连接字符串的代码(不错)
jsp怎么连接access数据库
js未结束的字符串常量异常解决方法
javascript字符串连接类代码一例
JSP开发入门(2)-JSP语法的基本原理
php字符串操作函数入门篇
servlet与jsp基础教程(12)-脚本元素、指令和预定义变量
jsp常见问题二
JDBC连接DB2数据库详解
jsp文件操作之追加文件

[关闭]
~ ~