Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unknown exception for FOP

807605Jun 19 2007 — edited Jun 19 2007
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: Invalid byte 2 of 2-byte UTF-8 sequence.
	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
MY code looks like:
public class 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2007
Added on Jun 19 2007
1 comment
318 views