引用
public void subString(String str,int ind){
byte[] bs = str.getBytes();
String result = "";
int count = 0;
if(str.length() > 0 && ind != 0 ){
//计数器
for(int i = 0 ; i <= ind - 1;i++){
if(bs[i]<0) {
count++;
}
}
System.out.println("count: " + count);
//截取一般汉字时必定为奇数,并且为负数。截取字符前进一。
if(bs[ind] < 0 && (count%2) != 0 ){
String temp = new String( bs,0,ind-1);
System.out.println("截取后的:" + temp);
}else{
String temp = new String( bs,0,ind);
System.out.println("正好不用截取的:" + temp);
}
}