Java Utililty Methods BigInteger from Stream

List of utility methods to do BigInteger from Stream

Description

The list of methods to do BigInteger from Stream are organized into topic(s).

Method

BigIntegerreadBigInteger(ByteArrayInputStream bais)
read Big Integer
return new BigInteger(readData(bais));
BigIntegerreadBigInteger(DataInputStream dis)
Read a (reasonably short) BigInteger from a DataInputStream param dis the stream to read from return a BigInteger
short i = dis.readShort();
if (i < 0) {
    throw new IOException("Invalid BigInteger length: " + i);
byte[] buf = new byte[i];
dis.readFully(buf);
return new BigInteger(1, buf);
BigIntegerreadBigInteger(InputStream input)
Read the signed arbitrary sized BigInteger BigInteger in vint format
BigInteger result = BigInteger.ZERO;
long work = 0;
int offset = 0;
long b;
do {
    b = input.read();
    if (b == -1) {
        throw new EOFException("Reading BigInteger past EOF from " + input);
...
BigIntegerreadBigInteger(int n, DataInput dis)
read Big Integer
BigInteger ret = BigInteger.ZERO;
byte[] temp = new byte[n];
dis.readFully(temp, 0, n);
for (int j = n - 1; j >= 0; j--) {
    ret = ret.or(BigInteger.valueOf(0xFF & temp[j]));
    ret = ret.shiftLeft(8);
ret = ret.shiftRight(8);
...
BigIntegerreadLineAsBigInteger(BufferedReader br)
Executes readline with the given buffered reader Converts the read string to an BigInteger
String str = br.readLine();
if (str == null) {
    throw new IOException();
return new BigInteger(str);
BigIntegerreadLuposBigInteger(final int numberOfBits, final InputStream is)

readLuposBigInteger.

BigInteger result = BigInteger.ZERO;
BigInteger factor = BigInteger.ONE;
final BigInteger BYTE = BigInteger.valueOf(256);
int remainingBits = numberOfBits;
while (remainingBits > 0) {
    final int currentValueByte = is.read();
    if (currentValueByte < 0) {
        return null;
...