public static String cutString(String str, int len) {
byte[] by = str.getBytes();
int count = 0;
try {
for(int i = 0; i < len; i++) {
if((by[i] & 0x80) == 0x80) count++;
}
if((by[len - 1] & 0x80) == 0x80 && (count % 2) == 1) len--;
return new String(by, 0, len);
}
catch(java.lang.ArrayIndexOutOfBoundsException e)
{
System.out.println(e);
return "";
}
}