java.io.UTFDataFormatException
When I try to create a file and try to parse it an error appears
this is my code:
Code:
FileWriter fw =null;
File file=null;
BufferedWriter bw=null;
String nodeName="";
String nodeval="";
System.out.println("XML String" + XMLString);
try {
double ran = Math.random();
fw= new FileWriter("content.xml");
file = new File("content.xml");
bw = new BufferedWriter(fw);
bw.write(XMLString);
bw.flush();
Document doc = docBuilder.parse(file); --
and the exception is that:
Code:
java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
at org.apache.xerces.impl.io.UTF8Reader.invalidByte
(Unknown Source)
at org.apache.xerces.impl.io.UTF8Reader.read
(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load
(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.peekChar
(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanCDATASection
(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch
(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument
(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:172)
at com.supportap.blp.ParserUtil.parseXMLContent(ParserUtil.java:128)
at com.supportap.blp.ParserUtil.main(ParserUtil.java:176)
any ideas?