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

Byte Array to Hex String 

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.convertBytesToHexString() 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 Bytes2HexStringTest {

   @param args
  public static void main(String[] args) {
    //Convert number to byte array
    byte [] bytes = ByteBuffer.allocate(4).putInt(17291729).array();
    //Convert byte array to hex string
    String hexStr = BinaryUtils.convertBytesToHexString(bytes);


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



Books Recommendation

bl  br