Java XML Hex toReadableHexString(byte[] array)

Here you can find the source of toReadableHexString(byte[] array)

Description

to Readable Hex String

License

Open Source License

Declaration

public static String toReadableHexString(byte[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.xml.bind.DatatypeConverter;

public class Main {
    public static String toReadableHexString(byte[] array) {
        String hex = DatatypeConverter.printHexBinary(array).toUpperCase();
        String finalHex = "";

        int temp = 0;
        for (char current : hex.toCharArray()) {
            if (temp == 2) {
                finalHex += " ";
                temp = 0;// w  w w  .  ja va2 s.co m
            }

            finalHex += current;

            temp++;
        }

        return finalHex;
    }
}

Related

  1. toHex(byte[] bytes)
  2. toHex(byte[] donnees)
  3. toHex(String str)
  4. toHexString(byte[] array)
  5. toHexString(byte[] edid)