Java XML Hex toHex(String str)

Here you can find the source of toHex(String str)

Description

to Hex

License

Open Source License

Declaration

public static String toHex(String str) 

Method Source Code


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

import javax.xml.bind.DatatypeConverter;

public class Main {
    public static String toHex(String str) {
        return toHex(str.getBytes());
    }//from ww w  .  j  a va  2s  .  c om

    public static String toHex(byte[] b) {
        return DatatypeConverter.printHexBinary(reverse(b));
    }

    public static byte[] reverse(byte[] b) {
        byte[] b2 = new byte[b.length];
        for (int i = 0; i < b.length; i++)
            b2[b.length - i - 1] = b[i];

        return b2;
    }
}

Related

  1. toByteArrayFromHexString(String s)
  2. toByteFromHexString(String hexString)
  3. toHex(byte[] bytes)
  4. toHex(byte[] bytes)
  5. toHex(byte[] donnees)
  6. toHexString(byte[] array)
  7. toHexString(byte[] edid)
  8. toReadableHexString(byte[] array)