如何在Java中打印字节数组?

您可以简单地迭代字节数组并使用System.out.println()方法打印字节。

示例

public class Tester {
   public static void main(String[] args) {
      byte[] a = { 1,2,3};
      for(int i=0; i< a.length ; i++) {
         System.out.print(a[i] +" ");
      }
   }
}

输出结果

1 2 3