Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!209.197.12.246.MISMATCH!nx02.iad01.newshosting.com!newshosting.com!216.196.98.142.MISMATCH!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, 22 Apr 2011 11:04:36 -0500 Date: Fri, 22 Apr 2011 09:04:34 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.java.help Subject: Re: Good practice or not to close the file before System.exit(1)? References: <87mxjjqmlf.fsf@merciadriluca-station.MERCIADRILUCA> <87ipu67b41.fsf@merciadriluca-station.MERCIADRILUCA> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 27 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.8.126.96 X-Trace: sv3-PNhzCSUIDhYCJX0QmdPwbBeWKU/gUi+ryJaeR9//BZVe7p59A2oBr+utYOJU8cB2nRE1V7fZshWXNi9!JlkJLAmrMg1nv/JAe7KnYDJj4i8CcaWDQs4Cdn4TPwz/JvWsDMjBD+kOysIw2Yhd2ARY5nfMlWFM!CWLgdW6z7OOhJoaQONDEMSnDxEg2to0l2A/r3JjSF94= 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: 2374 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:583 On 4/22/2011 8:20 AM, markspace wrote: > On 4/22/2011 4:56 AM, Merciadri Luca wrote: >> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >> >> The fact is that when some specific values of variables are >> encountered, the program can't continue. I would have preferred >> throwing an exception, but there is apparently no reason to throw >> an exception because the variables that need to be checked come >> directly from the arguments that the user passed to the JVM: >> >> java myprogram 1 2 3 > > > Doesn't matter, throw an exception. ... > In your particular case, yes you could almost certainly avoid opening > the files first. However in general this follows the same pattern > that all other exceptional processing follows: throw an error when > you have a problem, let the high level code catch it and deal with > the results. To take the extreme case of high level code, what is the main method of an application supposed to do when, through exceptions or otherwise, it finds out that the program should terminate with status code 1? Patricia