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

