when I tried to get an input of type Integer, what I only needed to do was the code below.
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
Make sure you prepare to catch an exception from the BigInteger - if the scanner fails to find a string you might get a BigInteger with non integer characters and it'll throw an exception.
Scanner scanner = new Scanner(fileOrOther);
try{
BigInteger bigint = scanner.nextBigInteger();
} catch(NumberFormatException ex) {
//handle Code here
}