// 按字节截取字符串,遇到中文不能截取半个,比如输入"中abc" 4 则,输出 "中ab"
public String sub_String(String inString,int count){
String st = inString;
if(null != st){
for (int i=0;i<count;i++){
String temp = st.substring(i,i+1);
byte[] by = temp.getBytes();
if(i==0&&count==1){
break;
}
if(by.length>1){
count = count-1;
}
}
if(count<0){
count = 0;
}
if(count>st.length()){
count = st.length();
}
st = st.substring(0,count);
}
return st;
}
public String sub_String(String inString,int count){
String st = inString;
if(null != st){
for (int i=0;i<count;i++){
String temp = st.substring(i,i+1);
byte[] by = temp.getBytes();
if(i==0&&count==1){
break;
}
if(by.length>1){
count = count-1;
}
}
if(count<0){
count = 0;
}
if(count>st.length()){
count = st.length();
}
st = st.substring(0,count);
}
return st;
}