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 trialAraz kuberin
6,199 PointsThere is no "songs.txt" file how can the program run without throwing something like FileNotfoundException???
When craig is adding a new song it will not create a file it just adds that song to a List!
so how come we do not get FileNotFoundException or something ??
4 Answers
andren
28,558 PointsThe file was not created when the song was added, it was created when he quit the program. The last line of code in the main function is this:
songBook.exportTo("songs.txt");
The exportTo
function was defined earlier and saves the song list to the disk.
Araz kuberin
6,199 PointsOK I understand now...but i just wonder if the program catches first time when trying to importFrom the catch should print System.out.printf("Problems loading %s %n", fileName); why does that not be printed in the video as well ?
andren
28,558 PointsIt was printed above the stack trace, the stack trace is just so long that it pushed the printed string above what you ended up seeing of the console in the video. If Craig had scrolled up when the error occurred you would have seen the error message string at the top.
Araz kuberin
6,199 PointsAnd i think in the second time we have already created a file therefore the error doesnt accour!
Araz kuberin
6,199 PointsThank You!!!
Araz kuberin
6,199 PointsAraz kuberin
6,199 PointsOK.. but first it imports when there is no song.txt file it should first export then importffrom. like..
public class Karaoke {
public static void main(String[] args) {
} }
andren
28,558 Pointsandren
28,558 PointsYes, and the first time the application is launched an error does actually occur as you can see at 9:18 in the video. But there is a catch clause setup for the exception which is why the program does not crash. I assumed you were asking about why the error did not occur the second time the application was launched.