-2
我想上懸而未決的問題,但仍然不能資助錯誤....的FileReader運行時錯誤
class ReadWriteFile extends Patron{
static void readFile (Patron p[]){
try{
File file = new File("patron.txt");
int cnt=0;
FileReader fr = new FileReader (file);
Scanner scan = new Scanner(fr);
String temp = scan.nextLine();
while(temp!=null){
System.out.print(temp);
String tempPatron[] = temp.split("|");
String id_codes = Integer.parseInt(tempPatron[0].trim());
String names = tempPatron[1];
String S_addresss = tempPatron[2];
int post_codes = Integer.parseInt(tempPatron[3].trim());
double overdue_balances = Double.parseDouble(tempPatron[4]);
String passwords =tempPatron[5];
p[cnt] = new Patron(id_codes, names, S_addresss, post_codes, overdue_balances, passwords);
// System.out.print(p[cnt]);
cnt++;
temp=scan.nextLine();
}
} catch (Exception ex){
//ex.printStackTrace();
}
}
}
什麼在這個error..when我裏面的文字掃描問題將由第一值誤差。 ...
? a d | A u n Z h i G i e | J a l a n K e p o n g | 5 2 1 0 0 | 1 . 0 0 | C 1 2 3 java.lang.NumberFormatException: For input string: "a"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at ReadWriteFile.readFile(patron.java:50)
at Main.main(Testingprogram.java:6)