0
이 class을 사용하여 XML을 구문 분석하려고합니다. 간단한 파일을 타이핑하면 잘 동작합니다. 무엇을 일으키는Java : MalformedByteSequenceException (XML)
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
: 여기
<testData>
<text>
odp
</text>
</testData>
내가 MSFT 오피스 OneNote의에서 복사 및 붙여 넣기로받은 파일을 사용할 때, 나는 오류를 얻을, 그러나 내
main
public static void main(String[] args) {
Xml train = new Xml(args[0], "trainingData");
Xml test = new Xml(args[1], "testData");
}
입니다 이? Notepad ++에서 문제가되는 XML 파일을 편집하고 인코딩을 UTF-8
으로 변경했습니다. 이로 인해 액센트/특수 인용 부호의 이상한 문자가 생겨 편집했습니다. 제대로 변환하지 않습니까?
어떻게 그런 16 진수 덤프를 생성 할 수 있습니까? –
Unix/Linux/Mac의 경우 "od -x file"을 사용하십시오. Windows에서 다음과 같은 도구를 다운로드해야합니다. http://www.richpasco.org/utilities/hexdump.html –
notepad ++와 같은 편집기를 사용하여 파일을 다시 인코딩하는 것으로 충분하지 않습니까? 나도 같은 문제 - 다른 컨텍스트 (개미 빌드에서 xml 조작) 및 불행히도 UTF-8 (비록 이미 UTF-8 이었지만) 파일을 다시 인코딩하면 어쨌든 도움이되지 않았습니다. – AgentKnopf