Java Exception handling Sequential File Processing

If you want to catch 3 types of exceptions, in other words, you will have 3 catch blocks, which one will you type first, the most specific exception? or the most general exception?
Who is Participating?
for_yanConnect With a Mentor Commented:
see example here:

File prefsFile = new File(prefsFilename);

catch (FileNotFoundException e)
    // alert the user that the specified file
    // does not exist
catch (EOFException e)
    // alert the user that the end of the file
    // was reached
catch (ObjectStreamException e)
    // alert the user that the file is corrupted
catch (IOException e)
    // alert the user that some other I/O
    // error occurred

Open in new window


You normally catch the most specific excpetion in the most
inner try - catch area
bakerule22Author Commented:
ok thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.