在Java中将字节转换为字符串

使用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