Java Hex Convert To fromHex(String hexData)

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

Description

from Hex

License

Apache License

Declaration

public static byte[] fromHex(String hexData) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] fromHex(String hexData) {
        byte[] result = new byte[(hexData.length() + 1) / 2];
        String hexNumber = null;/*from   w ww.  j  a va 2s. co  m*/
        int stringOffset = 0;
        int byteOffset = 0;
        while (stringOffset < hexData.length()) {
            hexNumber = hexData.substring(stringOffset, stringOffset + 2);
            stringOffset += 2;
            result[(byteOffset++)] = ((byte) Integer.parseInt(hexNumber, 16));
        }
        return result;
    }
}

Related

  1. fromHex(String hex)
  2. fromHex(String hex)
  3. fromHex(String hex)
  4. fromHex(String hex)
  5. fromHex(String hexBytes)
  6. fromHex(String hexStr)
  7. fromHex(String hexString)
  8. fromHex(String hexString)
  9. fromHex(String input, int max)