字节数组转字符串

public String byteTOString(byte[] src) {
	int idx = 0;
	for (idx = 0; idx < src.length; idx++) {
		if (src[idx] == (byte) 0) {
			break;
		}
	}
	try {
		return new String(src, 0, idx, "UTF-8");
	} catch (Exception e) {
		e.printStackTrace();
		return new String(src, 0, idx);
	}
}

猜你喜欢

转载自aijerry.iteye.com/blog/2101228