So following that code, which was only snippets and not the entire code which makes me think I am missing something, here is the code I came up with:
I have tried many variations of getResourceAsStream("C:/FilePath/apache-tomcat-6.0.18/wtpwebapps/NI/test.xml") such as just getResourceAsStream("test.xml") but the same thing happens each time
I call the loadXml() and then the print() method to see the values of data and it gives me this:
Exception in thread "main" java.net.MalformedURLException at java.net.URL.<init>(URL.java:601)
getResource() and getResourceAsStream don't accept absolute paths - they accept paths relative to the ClassLoader / Class. If you checked the result, I think you would have found that getResourceAsStream would have returned null.
I thought that was what I was trying to do with the print() method, check the result. It doesnt even seem to be getting that far, before it even attempts to print the value of data I get that. But I also tried getResourceAsStream("test.xml") and it gives me the same thing
Here is what the example on the RF dev guide has:
So where would they have had to put stations.xml to in order for the java code to know where to look>?
Class' getResource and getResourceAsStream can use a relative path, indicating the resource is located relative to the .class file, or an absolute path (starting with /) that indicates the resource is located relative to the class path. For instance, the following two both will try to find a file in the same path where String.class is located:
ClassLoader's getResource and getResourceAsStream are always absolute, but do not require the leading /: