??String str = "abc中国def";
??int p = 0;
??int trunc = 5;
??for (int i = 0; i < str.length(); i++)
??{
???if (trunc <= 0)
???{
????break;
???}
???// 中文占两个字节
???if (str.substring(i, i + 1).getBytes().length == 2)
???{
????p++;
????trunc -= 2;
???} else
???{
????p++;
????trunc--;
???}
??}
??System.out.println(str.substring(0,p));
?