dom4j读取中文问题

在项目中需要用dom4j来读取一片xml,但是却发生了异常,那位高人能指教一二哦!?
xml:
<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --> < root >< name > 阿拉進髮 </ name ></ root >

java程序

<!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --> String strXML  =   " <root><name>阿拉進髮</name></root> " ;
        String strTemplateInfo 
=   "" ;
        StringBuffer objBuffer 
=   new  StringBuffer(strXML);
        org.dom4j.io.SAXReader objReader 
=   null ;
        InputStream objBufferInput 
=   null ;
        org.dom4j.Document objDom 
=   null ;
        org.dom4j.Element objElement 
=   null ;
        
try  {
            strTemplateInfo 
=  objBuffer.toString();
            objBufferInput 
=   new  StringBufferInputStream(strTemplateInfo);
            objReader 
=   new  org.dom4j.io.SAXReader();
            objDom 
=  objReader.read(objBufferInput);
            objElement 
=  objDom.getRootElement();
            System.out.print (objElement.asXML());
        } 
catch  (Exception ex) {
            System.out.print (ex.getMessage());
            ex.printStackTrace();
        }



Exception:

rror on line 1 of document  : Invalid byte 2 of 2-byte UTF-8 sequence. Nested exception: Invalid byte 2 of 2-byte UTF-8 sequence.org.dom4j.DocumentException: Error on line 1 of document  : Invalid byte 2 of 2-byte UTF-8 sequence. Nested exception: Invalid byte 2 of 2-byte UTF-8 sequence.
    at org.dom4j.io.SAXReader.read(SAXReader.java:339)
    at org.dom4j.io.SAXReader.read(SAXReader.java:246)
    at oracle.erp.test.DataGetter.getXMLRoot(DataGetter.java:132)
    at oracle.erp.test.DataGetter.testXml(DataGetter.java:42)
    at oracle.erp.test.DataGetter.main(DataGetter.java:37)
Nested exception:
org.xml.sax.SAXParseException: Invalid byte 2 of 2-byte UTF-8 sequence.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1810)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
    at org.dom4j.io.SAXReader.read(SAXReader.java:323)
    at org.dom4j.io.SAXReader.read(SAXReader.java:246)
    at oracle.erp.test.DataGetter.getXMLRoot(DataGetter.java:132)
    at oracle.erp.test.DataGetter.testXml(DataGetter.java:42)
    at oracle.erp.test.DataGetter.main(DataGetter.java:37)
Nested exception: org.xml.sax.SAXParseException: Invalid byte 2 of 2-byte UTF-8 sequence.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1810)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
    at org.dom4j.io.SAXReader.read(SAXReader.java:323)
    at org.dom4j.io.SAXReader.read(SAXReader.java:246)
    at oracle.erp.test.DataGetter.getXMLRoot(DataGetter.java:132)
    at oracle.erp.test.DataGetter.testXml(DataGetter.java:42)
    at oracle.erp.test.DataGetter.main(DataGetter.java:37)


你可能感兴趣的:(java,apache,oracle,xml,sun)