• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

JBuilder 7 error: catch

I am getting this error in my code for catch;


try
    {
      SAXParserFactory spf =SAXParserFactory.newInstance
     ();
      SAXParser parser = spf.newSAXParser();
      XMLReader r = parser.getXMLReader();
    }
 catch(IOException e) {
      e.printStackTrace();
    }

Error:
The exception can never be thrown in the corresponding try block.
0
kaushalshah
Asked:
kaushalshah
1 Solution
 
warsqlCommented:
If you check the javadoc for the methods you are using in your try block, you will not find IOException.  That is why you are getting that error.

newInstance() throws FactoryConfigurationError
newSAXParser() throws ParserConfigurationException,
                      SAXException
getXMLReader() throws SAXException

So, you want to catch these exceptions instead.

0
 
CleanupPingCommented:
kaushalshah:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
jimmackCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept warsql's comment as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jimmack
EE Cleanup Volunteer
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now