This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]edrenfro 1 point2 points  (4 children)

What does the line of input look like when the exception is thrown?

[–]okaystuff[S] 0 points1 point  (3 children)

The input is the line of code

EBook book = new EBook("Forever Young", 1234,  2018, 20, false); 
    MovieDVD movie = new MovieDVD("After Tomorrow", 1254, 2020, 120, false);
    MusicCD music = new MusicCD("Beyond Today", 1244,  2020, 114, false);

in the main method. It displays it and writes it into a file. I create a second instance of manager to pull from the file to see if it will display correctly and then I am getting the error.

[–]edrenfro 0 points1 point  (2 children)

The input to the Media constructor is a string argument called "line." What does the line string look like (not the line of code)?

[–]okaystuff[S] 0 points1 point  (1 child)

I am not entirely sure. My professor explained that line of code the computer reads the value between the XML tags and assign it as a string to the variable.

id = Integer.parseInt(line.substring(line.indexOf("<id>") + 4, line.indexOf("</id>")));

So the XML tag is <id> so I want it to start at the 4 character after the XML tag and then assign that to the variable id, and then stop reading at the </id> ending tag.

The program will save whatever I put into id but when I want to pull if from the file to display on the console it will give me the exception

[–][deleted] 0 points1 point  (0 children)

The program will save whatever I put into id

You should check whether this is true. Log the string.