Unknown exception for FOP

I get this exception when I run my code in my program and I don't no what it means. It goes like

ERROR:'Invalid byte 2 of 2-byte UTF-8 sequence.'

javax.xml.transform.TransformerException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalidbyte 2 of 2-byte UTF-8 sequence.

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)

MY code looks like:

publicclass CreatePDF{

//Data Members

OutputStream out;

private FopFactory fopFactory = FopFactory.newInstance();

CreatePDF(String string){

try{

out =new BufferedOutputStream(new FileOutputStream(new File("C:/Temp/myfile.pdf")));

}catch (FileNotFoundException e){

// TODO Auto-generated catch block

e.printStackTrace();

}//end try catch

try{

FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

// Step 3: Construct fop with desired output format

Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,foUserAgent, out);

// Step 4: Setup JAXP using identity transformer

TransformerFactory factory = TransformerFactory.newInstance();

// System.out.println(string);

//Source xslt = new StreamSource(new File(string));

Transformer transformer = factory.newTransformer();// identity transformer

// Step 5: Setup input and output for XSLT transformation

// Setup input stream

Source src =new StreamSource(new File(string));

System.out.println(string);

// Resulting SAX events (the generated FO) must be piped through to FOP

Result res =new SAXResult(fop.getDefaultHandler());

// Step 6: Start XSLT transformation and FOP processing

transformer.transform(src, res);

}catch (FOPException e){

// TODO Auto-generated catch block

e.printStackTrace();

}catch (TransformerConfigurationException e){

// TODO Auto-generated catch block

e.printStackTrace();

}catch (TransformerException e){

// TODO Auto-generated catch block

e.printStackTrace();

}finally{

//Clean-up

try{

out.close();

}catch (IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}//end constructor

}//end class

Is anyone who is familiar with FOP know why this is happening? And the string that is passed prints out as : C:\Documents and Settings\jsmith\My Documents\metadata\AUDIO 653 (SAMSUNG) HT-Q45.xls

[4434 byte] By [blackmagea] at [2007-11-27 8:10:41]
# 1

That means this:

You are reading an XML document and assuming it is encoded in UTF-8, whereas it is actually encoded in some other encoding.

The encoding failure is not coming from your code, because you pass the parser a File object and it can look at the XML document and see what encoding it declares. The failure occurs because the XML document does not declare an encoding, and so the parser assumes it's encoded in UTF-8. (This is what parsers do by design.) But in fact whoever created the document used some other encoding to write it out, and failed to state that encoding in the document's prolog.

So you'll need to get your input document fixed up.

DrClapa at 2007-7-12 19:54:22 > top of Java-index,Java Essentials,Java Programming...