hereis我的代碼....我得到一個NumberFormatException異常和IDK的whow解決吧..新手,完全卡住,真正需要幫助數字格式例外,真正卡住
public class AcccountArray {
public static void main(String[] args)
{
//Scan the file and save account details to array
File file = new File ("customers.txt");
System.out.println("Path : " + file.getAbsolutePath());
try{
Scanner scanner = new Scanner("customers.txt");
String[][] Account = new String[Integer.valueOf(scanner.nextLine())][3];
for(int i=0;i<Account.length;i++)
{
Account[i][0]=scanner.nextLine();
//System.out.println(Account[i][0]);
Account[i][1]=scanner.nextLine();
//System.out.println(Account[i][1]);
Account[i][2]=scanner.nextLine();
//System.out.println(Account[i][2]);
}
scanner.close();
錯誤:
java.lang.NumberFormatException: For input string: "customers.txt"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.valueOf(Unknown Source)
at AcccountArray.main(AcccountArray.java:15)
li。 15是
String[][] Account = new String[Integer.valueOf(scanner.nextLine())][3];
解決了掃描儀的問題,但現在我得到一個FileNotFOiundException ...準備拉頭髮 – user2954611
你不是廁所國王在文件的正確位置(或者更好的資源)。 1+到@ Reimeus的回答。 –