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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.16.MISMATCH!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date Fri, 12 Aug 2011 14:31:03 -0500
Date Fri, 12 Aug 2011 12:31:01 -0700
From Patricia Shanahan <pats@acm.org>
User-Agent Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0
MIME-Version 1.0
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>
In-Reply-To <0f7fb5c4-6031-4778-9ef7-de757bbdda39@m5g2000prh.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Message-ID <pdOdneTOH6_l4tjTnZ2dnUVZ_uednZ2d@earthlink.com> (permalink)
Lines 17
X-Usenet-Provider http://www.giganews.com
NNTP-Posting-Host 70.230.203.65
X-Trace sv3-dnWegi6kKFqBKUaYoF+PgzQTsx/OAnPCrhwGwYMD5zC7XdWpWkty/RIhnSkIYYlDiRCrP0T74bkIPTu!toc4/NTwB5GoFuhC5cdtzw4xkep7TNYDNc2Df+Jf9THjqTiq2pR8TbVIsNlaXaXhxDoIe8IGy4rJ!ou5NzVCZ0q9BguDbFwKSl+NrlmFt8uUGe/NrVxvVzOk1Gw==
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 1941
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7054

Show key headers only | 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