Hallo Leute,
hier ist mein XML File:
und meine Methode:
und das zeigt mit der WTK nach dem Ausführen:
Bitte HELFT mir , was mache ich denn falsh?
hier ist mein XML File:
Code:
<root>
<option name="Strassenbahn" icon="tram.png" />
<option name="Bus" icon="tram.png" />
<option name="S-Bahn" icon="tram.png" />
<option name="Über" icon="tram.png" />
</root>
und meine Methode:
Code:
public void ParseMenu(){
boolean doJob=true;
int event;
String name;
KXmlParser parser=new KXmlParser();
InputStreamReader reader=new InputStreamReader(this.getClass().getResourceAsStream(menu_filename));
try{
parser.setInput(reader);
}catch(XmlPullParserException e){
System.err.println("Could connect parser with inputstream");
}
while(doJob){
try{
event=parser.next();
name=parser.getName();
if(event==KXmlParser.END_DOCUMENT){
doJob=false;
break;
}
if ((event == KXmlParser.START_TAG) && (name.startsWith("root"))) {
System.out.println(name + ":");
} else if ((event == KXmlParser.START_TAG) && (name.startsWith("option"))) {
System.out.print(" " + name + ":" + parser.getAttributeValue(0) + "-"+ parser.getAttributeValue(1));
}
}catch(XmlPullParserException e){
System.err.println("Sluchilas' hujnja s parserom");
}catch(IOException e){System.err.println("Pizdec fajlu");}
}
}
und das zeigt mit der WTK nach dem Ausführen:
Code:
Project settings saved
Building "Netzplan"
Build complete
Running with storage root DefaultColorPhone
Unable to create MIDlet Netzplan
java.lang.ArrayIndexOutOfBoundsException:
at com.sun.kvem.cldc.i18n.j2me.GenericReader.read(+139)
at java.io.InputStreamReader.read(+56)
at org.kxml2.io.KXmlParser.peek(+77)
at org.kxml2.io.KXmlParser.peekType(+5)
at org.kxml2.io.KXmlParser.nextImpl(+259)
at org.kxml2.io.KXmlParser.next(+23)
at Netzplan.ParseMenu(+58)
at Netzplan.<init>(+58)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+19)
at com.sun.midp.midlet.Selector.run(+22)
Execution completed.
750471 bytecodes executed
20 thread switches
747 classes in the system (including system classes)
4799 dynamic objects allocated (172148 bytes)
13 garbage collections (145100 bytes collected)
Bitte HELFT mir , was mache ich denn falsh?