Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired Efficiency! Custom Serialization

Pieter-Andries van der Berg
Pieter-Andries van der Berg
7,468 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
7,468 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