Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Catching disk full exception

843810Mar 24 2004 — edited Mar 26 2004
I'm sorry if this seems like a really stupid question but I'm having problems getting to grips with exception handling. I need to handle disk full exceptions in a specific manner. I understand that I can catch a group of errors with e.g.
catch(IOException e){ ...}
but the question I have is how do I determine that its a disk full error? The only way I can see is something like:
catch (Exception e) { 
if (e.getMessage().equals("There is not enough space on the disk")){
// Disk full handler
...
      }
else {
//General purpose exception handler
...
}
But this seems fraught with problems of localization and error text that's liable to change. I'd have thought that something like:
catch(DiskFullException e) 
would be possible but I can only find a relatively small number of exceptions that can be explicitly handled in this way.

Am I missing something, is my approach the only one or is there some deeper philosophy that I've missed?

Many thanks in advance for any enlightenment.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2004
Added on Mar 24 2004
7 comments
934 views