Java XML Hex toByteArray(String hex)

Here you can find the source of toByteArray(String hex)

Description

to Byte Array

License

Open Source License

Declaration

public static byte[] toByteArray(String hex) 

Method Source Code

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

import javax.xml.bind.DatatypeConverter;

public class Main {
    public static byte[] toByteArray(String hex) {
        if (hex.length() % 2 != 0) {
            hex = "0" + hex;
        }/*from w  w  w.j  a v  a 2  s  . c o m*/

        return DatatypeConverter.parseHexBinary(hex);
    }
}

Related

  1. readHexString(ByteBuffer buf)
  2. sha1Hex(final String text)
  3. sha1Hex(String data)
  4. sha1Hex(String message)
  5. stringToHex(String str)
  6. toByteArray(String hexDumpString)
  7. toByteArrayFromHexString(String s)
  8. toByteFromHexString(String hexString)
  9. toHex(byte[] bytes)