Java Java Data Structures Efficiency! Custom Serialization

Pieter-Andries van der Berg
Pieter-Andries van der Berg
4,817 Points

IndexOutOfBoundsException: Index 1 out of bounds for length 1

im following along with the videos in IntelliJ

but i get this error that is displayed in the title.

its in this piece of code:

public void importFrom(String fileName) throws IOException{
        try (
                FileInputStream fis = new FileInputStream(fileName);
                BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
                ) {
            String line;
            while ( (line = reader.readLine()) != null){
                String[] args = line.split("\\|");
                addSong(new Song(args[0], args[1], args[2]));
            }
        } catch (IOException ioe){
            System.out.printf("Problems loading %s %n", fileName);
            ioe.printStackTrace();
        }
    }

1 Answer

Pieter-Andries van der Berg
Pieter-Andries van der Berg
4,817 Points

Okay fixed the problem already:

I deleted songs.txt and started the program again and exited and started it and that fixed it for some reason