2013-08-16
public String getNeedString(String source, int requestLength) { int index = 0; //begin num int sumLength = 0; //sum length String result = ""; while(index < source.length) { char currentChar = source.charAt(index); int currentCharLenth = ("" + currentChar).getBytes().length(); sumlength += currentCharLength; if(sumlength>requestLength) { break; } result += currentChar; index++; } }