我想放弃,但我必须这样做,所以你是我最后的希望。我想这是一个简单的问题,但我看不出有什么问题。这是代码:
    int i = -1;
    String[][] dan = new String[20][13];
    try {
     FileReader odczytanie = new FileReader("Kontrahenci.txt");
     BufferedReader bufor = new BufferedReader(odczytanie);
     String str;
     str = bufor.readLine();
     System.out.println(str);
     while ((str = bufor.readLine()) != null) {
        i = i + 1;
        String[] ar = {null, null, null, null, null, null, null, null, null, null, null, null, null};
        ar=str.split("; ");
        for(int j = 0; j < 13; j++)
            dan[i][j] = ar[j];
        for(int j = 0; j < 13; j++)
            System.out.println(dan[i][j]);  
     }
     bufor.close();
    } catch (IOException e) {
           System.out.println("File Read Error");
        }
因此,当我尝试运行它时,我收到此错误:
"Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1"
对于这一行:
for(int j = 0; j < 13; j++)
    System.out.println(ar[j]);
在一个文件中,我有三行用分号分隔的单词。该代码适用于第一行,但在我收到错误之后。不知道出了什么问题。