I'm trying to read a long type from a text file using Scanner in Java. I get the following error:
Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:840) at java.util.Scanner.next(Scanner.java:1461) at java.util.Scanner.nextLong(Scanner.java:2196) at java.util.Scanner.nextLong(Scanner.java:2156) at Project.main(Project.java:119)
Which correlates to this line:
strLine = (long) in.nextLong();
If I do in.next() it will work, but I need to store the info as a long, not as a String. The exact number it's getting mad at reading is:
Anyone know how to fix this? Thanks in advance!
You should do:
strLine = (long) in.nextDouble();