Here you can find the source of toByteArray(BigInteger i)
public static byte[] toByteArray(BigInteger i)
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; import java.util.Arrays; public class Main { public static byte[] toByteArray(BigInteger i) { byte[] array = i.toByteArray(); if (array[0] == 0) { array = Arrays.copyOfRange(array, 1, array.length); }/* w ww . j ava2 s .c o m*/ return array; } }