Java XML Hex fromHex(String str)

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

Description

from Hex

License

Open Source License

Declaration

public static byte[] fromHex(String str) 

Method Source Code


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

import javax.xml.bind.DatatypeConverter;

public class Main {
    public static byte[] fromHex(String str) {
        return DatatypeConverter.parseHexBinary(new String(reverseHEX(str.getBytes())));
    }//w ww  . j  av a 2s.  c o  m

    public static byte[] reverseHEX(byte[] b) {
        byte temp;

        for (int i = 1; i < b.length; i = i + 2) {
            temp = b[i];

            b[i] = b[i - 1];
            b[i - 1] = temp;
        }

        return b;
    }
}

Related

  1. convertByteArrayToHexString(byte[] byteArray)
  2. convertStringToHex(String str)
  3. encodeHex(byte[] bytes)
  4. fromHex(String hex)
  5. fromHex(String hex)
  6. getBytes(String hex)
  7. getFreshExecutionId()
  8. hex(final byte[] bytes)
  9. hex2bin(String input)