Java BigInteger from Stream readLineAsBigInteger(BufferedReader br)

Here you can find the source of readLineAsBigInteger(BufferedReader br)

Description

Executes readline with the given buffered reader Converts the read string to an BigInteger

License

Open Source License

Parameter

Parameter Description
br reader of the keyfile

Exception

Parameter Description
IOException thrown if something went wrong with readline()
NumberFormatException thrown if read line can't be converted to a BigInteger

Return

Line as BigInteger

Declaration

public static BigInteger readLineAsBigInteger(BufferedReader br) throws IOException, NumberFormatException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

import java.io.IOException;
import java.math.BigInteger;

public class Main {
    /**//from   w ww  .  j  a  v a 2 s.  c  o m
     * Executes readline with the given buffered reader
     * Converts the read string to an BigInteger
     * @param br reader of the keyfile
     * @return Line as BigInteger
     * @throws IOException thrown if something went wrong with readline()
     * @throws NumberFormatException thrown if read line can't be converted to a BigInteger
     */
    public static BigInteger readLineAsBigInteger(BufferedReader br) throws IOException, NumberFormatException {
        String str = br.readLine();
        if (str == null) {
            throw new IOException();
        }

        return new BigInteger(str);
    }
}

Related

  1. readBigInteger(ByteArrayInputStream bais)
  2. readBigInteger(DataInputStream dis)
  3. readBigInteger(InputStream input)
  4. readBigInteger(int n, DataInput dis)
  5. readLuposBigInteger(final int numberOfBits, final InputStream is)