IOException

I'm having an IOException thrown... how can I determine which subclass it relates to, without having to catch all of the subclasses?
[140 byte] By [javaroba] at [2007-11-26 13:56:22]
# 1
> I'm having an IOException thrown... how can I> determine which subclass it relates to, without> having to catch all of the subclasses?If you would handle them differently then you should catch them differently.
zadoka at 2007-7-8 1:35:52 > top of Java-index,Java Essentials,Java Programming...
# 2
Yes, but do I need to handle all of the subclass exceptions?It's against this:socket.connect(new InetSocketAddress(dest_ip_addr, port), 10000);
javaroba at 2007-7-8 1:35:52 > top of Java-index,Java Essentials,Java Programming...
# 3
> Yes, but do I need to handle all of the subclass> exceptions?No, just handle the ones you want to handle a different way first. Then catch IOException and do handle the rest.
zadoka at 2007-7-8 1:35:52 > top of Java-index,Java Essentials,Java Programming...
# 4

And if there's only one particular class that you care about handling specially, and the others can be catchalled, then you can code that like this:try {

// whatever code

} catch(FileNotFoundException fnfe) {

// handle it

} catch(IOException ioe) {

// handle the rest

}

You have to code the catch clauses in that order, the more specialized classes first.

DrClapa at 2007-7-8 1:35:52 > top of Java-index,Java Essentials,Java Programming...
# 5
If it is thrown in some method you are using then you have to either handle it or throw it.
alien08o8a at 2007-7-8 1:35:52 > top of Java-index,Java Essentials,Java Programming...