简单的将byte[] 还原成了 String 值
[TOC]
代码:
public class Test0719 {public static void main(String[] args) {String text = "test";byte[] textBytes = text.getBytes();String content = byteToString(textBytes);System.out.println(textBytes + "\n" + content);}private static String byteToString(byte[] bytes) {if (null == bytes || bytes.length == 0) {return "";}String strContent = "";try {strContent = new String(bytes, "utf-8");} catch (UnsupportedEncodingException e) {e.printStackTrace();}return strContent;}
}
运行结果:

运行结果.png