public static String byteArrToString(byte[] data, String encoding) throws UnsupportedEncodingException {
int index = -1;
for (byte t : data) {
if (t != 0) {
index++;
}
}
byte[] result = new byte[index + 1];
System.arraycopy(data, 0, result, 0, index + 1);
return new String(result, encoding);
}
标签:index,修剪,java,字节,result,byte,data,String
From: https://www.cnblogs.com/hhddd-1024/p/16996196.html