[jdom-interest] SAXBuilder and java.net.URL
Ian Lea
ian at digimem.net
Mon May 27 02:15:57 PDT 2002
You could avoid the problem altogether by calling the
SAXBuilder build(java.io.File) method or just the
build(String) method. But if you want to use URLs I
would suggest creating a File instance and calling
its toURL() method. In some circumstances, with
some parsers, you may also need to call the URL
toExternalForm() method to get a valid systemId.
Either way this should spare you from working out
how many / characters you need to include.
--
Ian.
ian at digimem.net
> marisa at dinf.ne.jp (Marisa DeMeglio) wrote
>
> Hi,
>
> I am new to the list, and new to Java and JDOM. So far everything has
> worked very well, but I am having trouble with SAXBuilder when I try to use
> it with a java.net.url, that points to a file on my hard drive.
> Here are a few lines of code ...
>
> ------------------
> SAXBuilder sbuild = new SAXBuilder(false);
>
> //create a new URL, pointing to a file that exists
> java.net.URL amisxmlURL = new
> java.net.URL("file://e:/dev/AMIS/Java/config/amis.xml");
>
> //amisxmlURL.toString() is "file://e:/dev/AMIS/Java/config/amis.xml"
> Document xDoc = sbuild.build(amisxmlURL.toString()); //also I have tried
> using just amisxmlURL as the parameter
>
>
> Debugger tells me: Hit uncaught exception org.jdom.JDOMException
> Bottom status bar of JBuilder6 says: Cannot locate SAXBuilder.java from
> project source/class path
>
> ----however, when I do this:
>
> Document xDoc = sbuild.build("file:////e://dev//AMIS//Java//config//amis.xml");
>
> I have no problems. The correct document is returned. If I try to build
> a URL with "//" instead of "/", I get a Malformed URL exception.
> I hope this falls under the scope of this group; my apologies if not. Any
> advice would be greatly appreciated.
>
> Thank you,
>
> Marisa
----------------------------------------------------------------------
Searchable personal storage and archiving from http://www.digimem.net/
More information about the jdom-interest
mailing list