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
iftekhar uddin
4,194 PointsWhy is the IOException used?
I'm kind of confused in the do loop. Since the do loop uses "default" in order to say "you didn't put in one of the choices we wanted" what is the IOException used for? Is it just for any data that isn't even a character array?
sorry if this is a really simple minded question.
btw this is in the java track where we just made the karaoke machine in efficiency i believe.
1 Answer
Zuhayr Elahi
2,582 PointsIn general you have an IOException if that block of code is handling inputs and outputs. So if you are reading from a file or writing from a file. In general, the following cases are when there is a need to catch an IOException:
- You are reading from or writing to a file
- In cases where the same file is being used by multiple resources
- The file does not exist
I found a resource on the Oracle website that might help better understand when an IOException needs to be handled. https://docs.oracle.com/javase/tutorial/essential/exceptions/putItTogether.html
Let me know if I could help more.
iftekhar uddin
4,194 Pointsiftekhar uddin
4,194 PointsThanks =)