個byte至第20個byte存放英文名姓名,此時如果用內建的substring取1至10會出現問題,
需要自己重寫一個Method來解決。
private String mSubString(String toSub, int start, int end) {
String sub = null;
try {
byte[] mByte = toSub.getBytes("Big5");
byte[] subByte = Arrays.
copyOfRange(mByte, start, end);
sub = new String(subByte, "Big5");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(Medicine_price.class.getName()).
log(Level.SEVERE, null, ex);
}
return sub;
}
沒有留言:
張貼留言