字节数组转字符串

来源:互联网 发布:淘宝上的卫生巾能买吗 编辑:程序博客网 时间:2024/05/01 03:19
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);}}

 

0 0