Solved: The problem was that the integer's values were too high and thus could not be stored in a int, but rather had to be stored in a BigInteger.
This code is intended to read input from a file(shown below) and I would like it to be read as an int or parsed to an int as I need to be able to apply math to it. It always throws the exception, "InputMismatchException". I have read many other questions and their solutions and still to implement their solutions with little to no success. The solutions include parsing the string as an int, removing whitespace with "ReplaceAll".
Code:
String fileName = "SBOWorkSpace.txt";
Scanner sf = new Scanner(new File(fileName));
int lineint = sf.nextInt();
int finalnumbers = lineint * hour;
System.out.println(finalnumbers + hournum);
String linestring = sf.nextLine();
String nospaces = linestring.replaceAll("\\s+\\u00A0]+$", "");
int filetonumbers = Integer.parseInt(nospaces);
File:
46886794368454912286794394376459086711
Error:
Exception in thread "main" java.util.InputMismatchException: For input string: "46886794368454912286794394376459086711"
at java.util.Scanner.nextInt(Scanner.java:2097)
at java.util.Scanner.nextInt(Scanner.java:2050)
at Encryption.main(Encryption.java:881)