jsp页面中汉字换行的问题
public static String SplitLongWord(String String1,int int2)
{
if(String1==null)
return null;
else
{
int int3= String1.length();
StringBuffer StringBuffer4=new StringBuffer();
int int5=0;
int int6;
for(int6=0;int6 <int3;++int6)
{
char char7=String1.charAt(int6);
StringBuffer4.append(char7);
if(char7==32||char7==13)
int5=0;
else if(++int5> int2)
{
StringBuffer4.append( "\n ");
int5=0;
}
}
return StringBuffer4.toString();
}
}
上面这个函数是如果长度过长就加一个回车,可以在页面内分行,数字和英文都可以,汉字不行,请教怎么解决啊
------解决方案--------------------? it works :
public class Test {
public static void main(String[] args) {
String x = "啊吧才的俄飞个好i就看了吗你 ";
System.out.println(SplitLongWord(x, 1));
}
public static String SplitLongWord(String String1,int int2)
{
if(String1==null)
return null;
else
{
int int3= String1.length();
StringBuffer StringBuffer4=new StringBuffer();
int int5=0;
int int6;
for(int6=0;int6 <int3;++int6)
{
char char7=String1.charAt(int6);
StringBuffer4.append(char7);
if(char7==32||char7==13)
int5=0;