public class Test10 {
/*
*编写函数,从一个字符串中按字节数截取一部分,但不能截取出半个中文(GBK码表),
* 例如:从“HM程序员”中截取2个字节是“HM”,截取4个则是“HM程”,截取3个字节也要是"HM"而不要出现半个中文
*
**/
public static String Substring(String s, int length) throws Exception {
byte[] bytesBuffer = s.getBytes("GBK");
int bytesLength=bytesBuffer.length;
if(bytesLength<length)
return s;