UnsupportedEncodingException: UTF_8 Jdom

UnsupportedEncodingException: UTF_8 Jdom

我有这个代码java

String fichier= "movies.xml";
builder = new SAXBuilder();
xmlFile = new File(fichier);
document = (Document) builder.build(xmlFile);

但是当我执行这段代码时,我有一个关于编码的异常

Exception in thread "main" com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Octet 2 de la séquence UTF-8 à 4 octets non valide.
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:701)
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:473)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1793)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipChar(XMLEntityScanner.java:1463)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2824)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:905)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:884)

在线 "document = (Document) builder.build(xmlFile);"

所以,我该如何解决这个问题

提前致谢

评论总结:

关于第一条错误信息 (UnsupportedEncodingException: UTF_8)

UTF_8 不是有效编码,请改用 UTF-8。在您的 xml 文件中替换行

<?xml version="1.0" encoding="UTF_8"?>

<?xml version="1.0" encoding="UTF-8"?>

关于第二条错误信息 (MalformedByteSequenceException)

xml 的编码必须与声明的编码匹配。将xml文件的编码转换为UTF-8.