Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson 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 08:54:44 -0700 Organization: A noiseless patient Spider Lines: 39 Message-ID: References: <0f7fb5c4-6031-4778-9ef7-de757bbdda39@m5g2000prh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 12 Aug 2011 15:54:44 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="mz/LDSJwiWnk3Jnnqg7x+Q"; logging-data="2096"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18IUhaNgqTta4OFq26sGz9n" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: <0f7fb5c4-6031-4778-9ef7-de757bbdda39@m5g2000prh.googlegroups.com> Cancel-Lock: sha1:62cRJnGqQD5RBXvXuGThfCoeXaM= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7049 On 8/12/2011 8:39 AM, KevinSimonson wrote: > If I write a piece of code that constructs an object of class > by passing it an object of class, > constructed by passing _it_ an object of type (all three > classes under), don't have a clause, have only a > clause for, and then try to compile > the code the compiler complains, telling me, "unreported exception > java.io.IOException java.io.IOException: must be caught or declared to > be thrown". Of course, if I put a clause there for > , that fixes the problem and the program compiles just > fine. > > If, on the other hand, I write a piece of code that constructs an > object of class, constructed by passing it an object of type > , don't have a clause for, and > don't put the constructor call in a block at all, I get a > similar complaint about me not saying anything about exception > . > > Finally, if I have some code that has constructors for _both > and_, I have to have a clause for > _both and_, in order to keep the > compiler happy. But in such a situation I have not been able to find > a way to _actually get thrown_! What is the purpose of > having a block for if nothing I do with my code > will actually throw an that is not a > ? Or, alternately, is there something I can do > to _get_ an that is not a > thrown? > > I would appreciate any information anyone can give me on this. > > Kevin Simonson Show us the actual code. -- Knute Johnson