使用String(byte [])构造函数将byte []转换为String。
public class Tester { public static void main(String[] args) { String test = "I love learning Java"; byte[] bytes = test.getBytes(); String converted = new String(bytes); System.out.println(converted); } }
输出结果
I love learning Java