截取字符串,只截取前N个字节的字符
摘要:
publicvoidcutString(Stringstr,intn){Stringtemp;intcount=0;for(inti=0;i<str.length();i++){temp=str.charAt(i)+"";count+=temp.getBytes().length;if(count>n)break;System.out.print(temp);}}@TestpublicvoidtestString(){cutString("我ABC好的sfd",7);} 阅读全文
posted @ 2012-10-05 15:52 passer1991 阅读(413) 评论(0) 推荐(0)
浙公网安备 33010602011771号