G
guitarromantic
Hey everyone.
I need to read the ints (specifically, to find the highest) from a text
file structured like this:
Surname 100
Foo 12
Bar 13 etc
My code to loop through the values gives an error despite compiling:
int highestSales = Integer.MIN_VALUE;
while (salesTextFile.hasNext())
{
int i = salesTextFile.nextInt();
if (i > highestSales)
{
highestSales = i;
System.out.println(highestSales);
}
}
(salesTextFile is a BufferedReader/FileReader input stream). This code
gives me an InputMismatchException error - any help?
Matt
I need to read the ints (specifically, to find the highest) from a text
file structured like this:
Surname 100
Foo 12
Bar 13 etc
My code to loop through the values gives an error despite compiling:
int highestSales = Integer.MIN_VALUE;
while (salesTextFile.hasNext())
{
int i = salesTextFile.nextInt();
if (i > highestSales)
{
highestSales = i;
System.out.println(highestSales);
}
}
(salesTextFile is a BufferedReader/FileReader input stream). This code
gives me an InputMismatchException error - any help?
Matt