Converts a BigInteger into a hex string. - Java java.math

Java examples for java.math:BigInteger

Description

Converts a BigInteger into a hex string.

Demo Code

// This program is free software; you can redistribute it and/or
import java.util.Random;
import java.math.BigInteger;
import java.io.PrintWriter;

public class Main{
    public static void main(String[] argv) throws Exception{
        BigInteger bi = new BigInteger("1234");
        System.out.println(to_byte_hex_string(bi));
    }/*from   w ww  .ja v  a  2  s . c  o  m*/
    /**
     * 
     * Converts a {@link BigInteger} into a hex string. In contrast to
     * {@link BigInteger#toString(int) BigInteger.toString(16)}
     * 4-digit-groups are separated by points, like 23EA.4F11...
     * 
     * @param bi BigInteger to convert
     * @return hex string
     */
    public static String to_byte_hex_string(BigInteger bi) {
        return Misc_host.to_byte_hex_string(bi.toByteArray());
    }
}

Related Tutorials