print Byte Array - Java java.lang

Java examples for java.lang:byte Array to int

Description

print Byte Array

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte[] byteArray = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        printByteArray(byteArray);/*from   ww w.jav  a2  s . c om*/
    }

    public static void printByteArray(byte[] byteArray) {
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < byteArray.length; i++)
            sb.append(String.format("%02X ", byteArray[i]));

        System.out.print(sb.toString());
    }
}

Related Tutorials