Java: MalformedByteSequenceException (XML)
Je suis en train d'essayer de parser XML à l'aide de cette classe. Lorsque je tape un simple fichier, il fonctionne très bien.
<testData>
<text>
odp
</text>
</testData>
Voici mon main
public static void main(String[] args) {
Xml train = new Xml(args[0], "trainingData");
Xml test = new Xml(args[1], "testData");
}
Cependant, lorsque j'utilise le fichier que j'ai obtenu par copie et coller à partir de MSFT Office OneNote, j'ai des erreurs:
Exception in thread "main" java.lang.RuntimeException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
at odp.compling.Xml.rootElement(Xml.java:41)
at odp.compling.Xml.<init>(Xml.java:61)
at odp.compling.ParseTreeAnalysis2.main(ParseTreeAnalysis2.java:10)
Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipChar(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at odp.compling.Xml.rootElement(Xml.java:33)
... 2 more
Quelle en est la cause? J'ai édité la problématique fichier XML Notepad++ et a changé l'encodage de UTF-8
. Cela a provoqué un tas de caractères bizarres à partir de l'accent spécial guillemets qui j'ai édité sur. Je ne suis pas convertir correctement?
(Je ne sais rien à propos de formats d'encodage de texte, dans le cas où vous ne pouvait pas dire.)
Vous devez vous connecter pour publier un commentaire.
Votre fichier n'est pas correctement encodés au format UTF-8, mais votre analyseur attend l'encodage UTF-8.
Il permettrait de cerner le problème, c'est que vous pouvez poster un convertir le fichier.