0

hi,

this is dhana. this is my first post, i am little nervous. i am developing a j2me application, i used xml file as database. so, i created a xml file and i saved it in c:\ , when i am trying to open that file in j2me, it shows error. the code is as below:

c =(StreamConnection)Connector.open("c:\\addressbook.xml");
      s = c.openInputStream();
       Reader is= new InputStreamReader(s);
      KXmlParser parser = new KXmlParser();
      Document document = new Document();
      parser.setInput(is);

i am getting arror as below:

C:\Users\DHANA\Documents\NetBeansProjects\AddressBook\src\AddressDB.java:128: unreported exception org.xmlpull.v1.XmlPullParserException; must be caught or declared to be thrown
parser.setInput(is);
C:\Users\DHANA\Documents\NetBeansProjects\AddressBook\src\AddressDB.java:129: unreported exception org.xmlpull.v1.XmlPullParserException; must be caught or declared to be thrown
document.parse(parser);
2 errors
C:\Users\DHANA\Documents\NetBeansProjects\AddressBook\nbproject\build-impl.xml:368: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 3 seconds)

so, can anyone solve my problem. thanks in advance.

Edited by Nick Evan: added code tags

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by NewColours
0

You have to wrap it in a try-catch block like it tells you.

I think c:\\ will need to be c:\ too if its a local file, otherwise it'll need to be a valid protocol.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.