What I Hate About Your Programming Language
Subject:   Java + Exceptions
Date:   2003-05-15 16:42:08
From:   anonymous2
Response to: Java + Exceptions

Why would you open a file for reading if you don't think it is going to be there?

If you ask to open a file and it does not exist then, yes, it is an exceptional condition.

Also if you wrote the code in, say, C and you didn't check the return of fopen you would "need" to put a comment to make the intent clear. Why put a comment that can easily be wrong after modifying the code if the compiler can do it for free?

Also if you open a file AND it doesn't exist you would need to check that the return value was not null... messy boilerplate code that is easy to get wrong and hides the logic of the program.

Please give a clear, concise, somewhat complete example of what you are saying you want - to open a file that may/may not exist and have it be fine either way AND detail what you would rather go through than deal with exceptions.

1 to 1 of 1
1 to 1 of 1