tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Uncommons Maths > Hex String to Byte Array

Hex String to Byte Array 

Uncommons Maths is a java library with nice math utilities and random number generators. This requires the library uncommons-maths-1.2.2.jar to be in classpath. The following example shows using BinaryUtils.convertHexStringToBytes() API.

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.uncommons;

import java.nio.ByteBuffer;
import java.util.Arrays;

import org.uncommons.maths.binary.BinaryUtils;

public class HexString2BytesTest {

   @param args
  public static void main(String[] args) {
    String hexStr = "0107D9D1";
    //Convert hex string to byte array
    byte [] bytes =  BinaryUtils.convertHexStringToBytes(hexStr);
    //Convert byte array to number


It gives the following output,
[1, 7, -39, -47]



Books Recommendation

bl  br