Java Hex Convert To fromHex(String hexStr)

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

Description

from Hex

License

Open Source License

Declaration

public static byte[] fromHex(String hexStr) 

Method Source Code

//package com.java2s;
/**//from  w  w  w  . j ava  2s .  c  o  m
 * Copyright (c) 2015 by SAP Labs Bulgaria,
 * url: http://www.sap.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of SAP AG, Walldorf. You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms
 * of the license agreement you entered into with SAP.
 * 
 * Created on Mar 18, 2015 by I052264
 *   
 */

public class Main {
    public static byte[] fromHex(String hexStr) {
        int byteSize = 2;
        byte[] result = new byte[hexStr.length() / byteSize];
        for (int i = 0; i < hexStr.length() / byteSize; i++) {
            String current = hexStr.substring(byteSize * i, byteSize * (i + 1));
            result[i] = (byte) Integer.parseInt(current, 16);
        }
        return result;
    }
}

Related

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