???????????????????????
??????????????????????????????
?????????????????????????????????????????????
????????????????????????????
????????????????????????
private String str; private int counterOfDoubleByte; private byte b[]; public void setLimitLengthString(String str){ this.str = str; } public String getLimitLengthString(int len, String symbol) throws UnsupportedEncodingException { counterOfDoubleByte = 0; b = str.getBytes("GBK"); if(b.length <= len) return str; for(int i = 0; i < len; i++){ if(b[i] < 0) counterOfDoubleByte++; } if(counterOfDoubleByte % 2 == 0) return new String(b, 0, len, "GBK") + symbol; else return new String(b, 0, len - 1, "GBK") + symbol; } ??????????????????? public String substring(String str, int toCount, String more) ...{ int reInt = 0; String reStr = ""; if (str == null) return ""; char[] tempChar = str.toCharArray(); for (int kk = 0; (kk < tempChar.length && toCount > reInt); kk++) ...{ String s1 = str.valueOf(tempChar[kk]); byte[] b = s1.getBytes(); reInt += b.length; reStr += tempChar[kk]; } if (toCount == reInt || (toCount == reInt - 1)) reStr += more; return reStr; } ????????????????? public static String substring(String str, int toCount,String more) { int reInt = 0; String reStr = ""; if (str == null) return ""; char[] tempChar = str.toCharArray(); for (int kk = 0; (kk < tempChar.length && toCount > reInt); kk++) { String s1 = str.valueOf(tempChar[kk]); byte[] b = s1.getBytes(); reInt += b.length; reStr += tempChar[kk]; } if (toCount == reInt || (toCount == reInt - 1)) reStr += more; return reStr; }