Требуется помощь по следующему коду:
package pkgPeople;
import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class RetrieveNonSerializedFile {
public static void main(String[] args) throws Exception{
File inFile = new File("F:/CS9.27/friends2.dat");
Scanner reader = new Scanner(inFile);
while (reader.hasNextLine()){
String nm = reader.nextLine();
int height = reader.nextInt();
int weight = reader.nextInt();
double balance = reader.nextDouble();
long acctID = reader.nextInt();
System.out.println(nm + ":" + height + " inches " + weight + " pounds" + acctID + " account ID" + balance + "dollars");
/*writer.println(nm);
writer.println(height);
writer.println(weight);
writer.println(acctID);
writer.println(balance);*/
}
reader.close();
//writer.close();
}
}
При запуске программы выдается исключение
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at pkgPeople.RetrieveNonSerializedFile.main(RetrieveNonSerializedFile.java:22)
.
файл данных, который имеет следующий .....
Jim is the name of the person.
13 inches is the height of Jim.
14 pounds is the weight of Jim
1234.650000 dollars is the balance of Jim
12345 is the ID of the bank account.
Это просто текстовый файл.Любая помощь, чтобы пройти через InputMismatch была бы отличной.Спасибо.