Java使用StringBuilder在字符串指定位置插入字符串

 // 设置content的时候,如果长度过长的话,可以裁剪掉。
            if (tempDesc.length()>10){

                StringBuilder sb = new StringBuilder(tempDesc);//构造一个StringBuilder对象
                sb.insert(10, "\n");//在指定的位置1,插入指定的字符串
                tempDesc = sb.toString();

            }

猜你喜欢

转载自blog.csdn.net/yu540135101/article/details/84340753