D3C0Y
Legacy Member
Ik probeer in mijn applet een extern xml bestand aan te roepen om de inhoud te kunnen lezen en gebruiken in mijn applet. Het bestand staat (voorlopig) nog op mijn webspace van telenet (dus mischien ligt het probleem hier), maar wanneer ik probeer in te lezen van het bestand krijg ik altijd errors
dit is console log:
mijn java code is
kheb de URL ff gehardcodet om te kijken of het daar aan lag (normaal gezien wordt de String filename voor de URL gebruikt), maar dat geeft hetzelfde resultaat
iemand een idee wat ik verkeerd doe ?
dit is console log:
Code:
network: Connecting http://users.telenet.be/decoy/FacebookApp/xml/BulletType.xml with proxy=DIRECT
network: Connecting http://users.telenet.be/crossdomain.xml with proxy=DIRECT
network: Connecting http://users.telenet.be:80/ with proxy=DIRECT
network: Connecting http://users.telenet.be/crossdomain.xml with cookie "__utmz=226366239.1223468593.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); st8id_wlf_%2Etelenet%2Ebe_%2F=TE5HVExNX0ZMQVNI?81c37b0684bbf41f4c42c63db814f879; __utma=226366239.605535372.1223468593.1223556298.1224764225.3"
network: Connecting http://www.zita.be/users_error/ with proxy=DIRECT
network: Connecting http://www.zita.be:80/ with proxy=DIRECT
java.security.PrivilegedActionException: java.io.FileNotFoundException: http://www.zita.be/users_error/
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.deploy.net.CrossDomainXML.check(Unknown Source)
at com.sun.deploy.net.CrossDomainXML.check(Unknown Source)
at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at facebookgame.parsing.XmlParser.SearchXml(XmlParser.java:38)
at facebookgame.entity.ShotEntity.<init>(ShotEntity.java:62)
at facebookgame.InGameState.Enter(InGameState.java:75)
at facebookgame.FacebookApp.changeToState(FacebookApp.java:258)
at facebookgame.MenuState.CheckPlayerInput(MenuState.java:106)
at facebookgame.MenuState.StateCycle(MenuState.java:139)
at facebookgame.FacebookApp.gameLoop(FacebookApp.java:212)
at facebookgame.FacebookApp.access$200(FacebookApp.java:17)
at facebookgame.FacebookApp$1.run(FacebookApp.java:60)
Caused by: java.io.FileNotFoundException: http://www.zita.be/users_error/
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.deploy.net.CrossDomainXML$2.run(Unknown Source)
... 22 more
mijn java code is
Code:
public Vector SearchXml(String filename, String typeList, int typeNumber)
{
Vector <Object> parsedList = new Vector();
try
{
// 1. Build the document with SAX and Xerces, no validation
SAXBuilder builder = new SAXBuilder();
System.out.println("build SAX");
// 2.Create the document
InputStream filesource = new URL("http://users.telenet.be/decoy/FacebookApp/xml/BulletType.xml").openStream();
System.out.println("found input source");
Document doc = builder.build(filesource);
System.out.println("Created document");
// 3. Create a root Element for fast use
Element root = doc.getRootElement();
System.out.println("got rootElement");
// 4. Check all childNodes of root for typeNumber
for (int i=0;i<root.getChildren().size();i++)
{
// I. cast the current child into a temporary Element
Element temp = (Element) root.getChildren().get(i);
// II. if the current child has the right type, push his children back into vector
if (temp.getAttribute("type").getIntValue() == typeNumber)
{
for (int j=0;j<temp.getChildren().size();j++)
{
parsedList.set(j, temp.getChildren().get(j));
}
return parsedList;
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
}
kheb de URL ff gehardcodet om te kijken of het daar aan lag (normaal gezien wordt de String filename voor de URL gebruikt), maar dat geeft hetzelfde resultaat
iemand een idee wat ik verkeerd doe ?

en het is mij aangeleerd dat een vector efficienter omspringt met geheugengebruik (toch in c++), en dat van die accolades tja ik werk graag overzichtelijk 

Dat hangt van de gebruikte coding convention af, uit ervaring weet ik ondertussen dat ze allebei afwisselend bij grote bedrijven worden voorgeschreven (niet specifiek voor Java alleen overigens). De grappigste zijn wel die die beide methodes door elkaar gebruiken in hun conventie, vb. bij functie declaraties moet je de accolades onder elkaar zetten, bij if ... else (en herhalingen) op dezelfde regel. Dat maakt het er voor mij niet overzichtelijker op, maar soit, klant is koning.