Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.math.BigInteger;

public class Main {
    /**
     * Converts a little endian byte array to a BigInteger.
     *
     * @param bytes The bytes to convert.
     * @return The resulting BigInteger.
     */
    public static BigInteger toBigInteger(final byte[] bytes) {
        final byte[] bigEndianBytes = new byte[bytes.length + 1];
        for (int i = 0; i < bytes.length; ++i) {
            bigEndianBytes[i + 1] = bytes[bytes.length - i - 1];
        }

        return new BigInteger(bigEndianBytes);
    }
}