Kevin,

That reminds me of some code I inherited:

if (file.exists()) {
  try {
    new FileInputStream(file)....
  }
  catch (FileNotFoundException e) {
    //impossible since we checked the file before
  }
}

Guess what?  It wasn't impossible, it happened occasionally because of a
flaky shared drive.  File systems are not under the program's control, so it
is unsafe to check-then-assume.  Even worse, the above would not work for
files that only come into existence when opened, like nodes in /dev, /proc
or /mnt on some systems.

On Wed, Sep 22, 2010 at 12:03 AM, Kevin Wright <[email protected]>wrote:

> In what context?
>
> When opening a named file, it should be normal control flow to discover the
> name isn't valid.
> When performing subsequent operations on an already-opened handle, it's
> truly exceptional if the thing has since gone missing,
>
> combining the operations is just poor design
>
>
> 2010/9/21 Cédric Beust ♔ <[email protected]>
>
>>
>>
>> On Tue, Sep 21, 2010 at 3:47 PM, Kevin Wright 
>> <[email protected]>wrote:
>>
>>> What would you propose as a good example?
>>>
>>
>> An example of a good checked exception?
>>
>> How about FileNotFoundException?
>>
>> --
>> Cédric
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "The Java Posse" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<javaposse%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/javaposse?hl=en.
>>
>
>
>
> --
> Kevin Wright
>
> mail / gtalk / msn : [email protected]
> pulse / skype: kev.lee.wright
> twitter: @thecoda
>
>  --
> You received this message because you are subscribed to the Google Groups
> "The Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<javaposse%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to