Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7058
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!postnews.google.com!l11g2000prh.googlegroups.com!not-for-mail |
|---|---|
| From | KevinSimonson <kvnsmnsn@hotmail.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Trying to Understand Purpose of a Catch Block for IOException in the Presence of One for FileNotFound |
| Date | Fri, 12 Aug 2011 13:10:57 -0700 (PDT) |
| Organization | http://groups.google.com |
| Lines | 39 |
| Message-ID | <112ceef7-dd08-4573-aa5f-a4c9779fdde7@l11g2000prh.googlegroups.com> (permalink) |
| References | <0f7fb5c4-6031-4778-9ef7-de757bbdda39@m5g2000prh.googlegroups.com> <pdOdneTOH6_l4tjTnZ2dnUVZ_uednZ2d@earthlink.com> |
| NNTP-Posting-Host | 216.49.181.254 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | posting.google.com 1313179857 1742 127.0.0.1 (12 Aug 2011 20:10:57 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Fri, 12 Aug 2011 20:10:57 +0000 (UTC) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | l11g2000prh.googlegroups.com; posting-host=216.49.181.254; posting-account=gsXmKQkAAADuyNfZpkeBrCCcqQvlDvn9 |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-Header-Order | ARLUEHNKC |
| X-HTTP-UserAgent | Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322; InfoPath.2; .NET4.0E; .NET4.0C),gzip(gfe) |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7058 |
Show key headers only | View raw
On Aug 12, 1:31 pm, Patricia Shanahan <p...@acm.org> wrote:
> 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
Patricia, you were absolutely right! Following up on your puzzlement,
I rewrote the program I posted, taking out the <import> of
<FileNotFoundException> and consolidating my <catch> blocks into:
catch (IOException excptn)
{ System.out.println();
System.out.println( "Couldn't open file!");
System.out.println( "<srcOpnd> == " + srcOpnd + '.');
}
This works just fine. All I can think of is that when I tried to
compile a program that just took input the compiler complained about
<FileNotFound> and when I tried to compile a program that just wrote
output the compiler complained about <IOException>, so maybe I just
_assumed_ that a program that both read input and wrote output would
need both exceptions!
Anyhow, thanks for pointing me in the right direction.
Kevin Simonson
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
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