Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #7054

Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound

Date 2011-08-12 12:31 -0700
From Patricia Shanahan <pats@acm.org>
Newsgroups comp.lang.java.programmer
Subject Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound
References <0f7fb5c4-6031-4778-9ef7-de757bbdda39@m5g2000prh.googlegroups.com>
Message-ID <pdOdneTOH6_l4tjTnZ2dnUVZ_uednZ2d@earthlink.com> (permalink)

Show all headers | View raw


On 8/12/2011 8:39 AM, KevinSimonson wrote:
...
> Finally, if I have some code that has constructors for _both
> <PrintWriter>  and_<Scanner>, I have to have a<catch>  clause for
> _both<IOException>  and_<FileNotFoundException>, in order to keep the
> compiler happy.
...

This is the most puzzling part of your question. FileNotFoundException
is a subclass of IOException, so a catch clause for IOException should
be sufficient.

Of course, if you want to deal with FileNotFoundException separately you
do have the option of putting in a separate catch clause for it, but the
compiler should not be requiring both.

Patricia

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound KevinSimonson <kvnsmnsn@hotmail.com> - 2011-08-12 08:39 -0700
  Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound Knute Johnson <september@knutejohnson.com> - 2011-08-12 08:54 -0700
  Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound markspace <-@.> - 2011-08-12 08:57 -0700
    Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound KevinSimonson <kvnsmnsn@hotmail.com> - 2011-08-12 11:19 -0700
      Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound markspace <-@.> - 2011-08-12 12:08 -0700
        Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound Patricia Shanahan <pats@acm.org> - 2011-08-12 12:26 -0700
      Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-08-12 19:35 +0000
  Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound Patricia Shanahan <pats@acm.org> - 2011-08-12 12:31 -0700
    Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound KevinSimonson <kvnsmnsn@hotmail.com> - 2011-08-12 13:10 -0700
  Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound Lew <lewbloch@gmail.com> - 2011-08-12 14:27 -0700

csiph-web