[jdom-interest] JDOM Exception??

RYAN HERRING RYAN.HERRING at morningstar.com
Fri Jun 16 14:05:51 PDT 2000


Hi,

I'm new to JDOM and I'm trying to run the PrettyPrinter example.  It
compiles, but when I try to run it, I get this error message:

D:\JavaXML\JDom>java JDomTest2 jreport.xml
org.jdom.JDOMException: String index out of range: 0: String index out of
range: 0
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:229)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:284)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:265)
        at JDomTest2.main(JDomTest2.java:18)
Root cause: java.lang.StringIndexOutOfBoundsException: String index out of
range: 0
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:834)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:218)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:284)
        at org.jdom.input.SAXBuilder.build(SAXBuilder.java:265)
        at JDomTest2.main(JDomTest2.java:18)

I'm using a sample XML file that I created, and I'm using that as my command
line argument.  Also, here is my source code:

import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;

public class JDomTest2 {
	public static void main(String[] args) {

		// filename argument
		String filename = args[0];
		try {
			// build the document with SAX and Xerces, no
validation
			SAXBuilder builder = new SAXBuilder();
			//Create the document
			Document doc = builder.build(new File(args[0]));

			//output the document
			XMLOutputter fmt = new XMLOutputter();
			fmt.output(doc, System.out);
		} catch (Exception e) {
			 e.printStackTrace();
		}
	}
}

Thanks in advance - Ryan Herring



More information about the jdom-interest mailing list