format Bytes as String - Java File Path IO

Java examples for File Path IO:Byte Array

Description

format Bytes as String

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte bytes = 2;
        System.out.println(formatBytes(bytes));
    }/*from   w  ww  .j  a  va2s  .c  o  m*/

    public static String formatBytes(byte... bytes) {
        StringBuilder sb = new StringBuilder(bytes.length * 3);
        for (byte byt : bytes) {
            sb.append(String.format("%02X ", byt));
        }
        return sb.toString();
    }
}

Related Tutorials