Why does it throw an exception?
In the video, Craig say, String choice = mReader.readLine(); throws an exception, "IOException". My question is why does it throw an IOException?
Tonnie FanadezUX Design Techdegree Student 15,032 Points
A file system read can fail for many reasons at any time e.g. the file is deleted or network errors or other OS errors.
An exception is thrown because you can't know or predict what will happen with code in case of the problems noted above. Therefore the programmer should think ahead and take care of any occurrences by catching the exceptions on try-catch block.