解决方案 »
- 这个怎么用Eclipse发布到tomcat里面去?
- 求帮助,在学习hibernate时遇到的问题,
- Unable to instantiate Action, 原因求解
- proguard 混淆器怎么用!请不要复制网上的!
- 引用org.springframework.orm出错,一直是找不到这个包
- EE SSH 加UPD/TCP服务?
- java web start如何与javascript交互?
- 执行servlet的时候报405 GET not supported,这是个什么错啊?
- sina的有些调查问卷,参与过后再次参与则提示我已参与过,它是如何记录我的信息的?
- log4j的问题
- 关于struts2框架中在页面中取action中的全局变量的问题。
- 集群环境JMS消息重复
// 避免错误信息字符串过长,截取前200个字符
if (!StringUtil.isEmpty(errorMessage)) {
byte[] errorArr = errorMessage.getBytes();
if (errorArr.length > 200) {
errorArr = Arrays.copyOf(errorArr, 200);
errorMessage = new String(errorArr);
}
}
这种方法我试过了...还是不行....
我是这么干的
for(int i=0; i<str.length(); i++){
char c =str.charAt(i);
if(c>255){
total+=3; //ZHS16GBK,占用2个字节,AL32UTF8,占3个字节
}else{
total+=1;
}
if(total>200){
break;
}else{
out.append(String.valueOf(c));
}
}
这种方法我试过了...还是不行....
我是这么干的
for(int i=0; i<str.length(); i++){
char c =str.charAt(i);
if(c>255){
total+=3; //ZHS16GBK,占用2个字节,AL32UTF8,占3个字节
}else{
total+=1;
}
if(total>200){
break;
}else{
out.append(String.valueOf(c));
}
}
恩 再具体的就是要分析字符编码格式了,不同的编码格式,同一个字符按照不同编码占用字节数可能是不同的