Skip to Content

This document is intended to change the encoding type of any document using java mapping. I have written a code which is commented in the below code which can help to remove the special characters also.












public class EncodFile extends AbstractTransformation {

          String strData =  null;


          public void transform(TransformationInput arg0, TransformationOutput arg1)

                              throws StreamTransformationException {

                    // TODO Auto-generated method stub

                    getTrace().addInfo(“File Reading started “);

                    String strData = convertStreamToString(arg0.getInputPayload().getInputStream());

                    getTrace().addInfo(“File Reading successfully completed “);

                    //  If special characters needs to be removed un-comment next two lines.

                    //          strData = strData.replaceAll(“[^\\p{ASCII}]”, “”);

                    //          getTrace().addInfo(“Bugs removed”);


                    try {

                              getTrace().addInfo(“Generating XML started”);

                              // Specify the Encoding type you would like to have in Below line(un comment one you like).


                              //          arg1.getOutputPayload().getOutputStream().write(strData.getBytes(“ISO-8859-1”));


                              getTrace().addInfo(“Generating XML started”);


                    } catch (IOException e) {

                              // TODO Auto-generated catch block





          public String convertStreamToString(InputStream in){

                    StringBuffer sb = new StringBuffer();



                    InputStreamReader isr = new InputStreamReader(in);

                    Reader reader =

                    new BufferedReader(isr);

                    int ch;

                    while((ch = > -1) {




                    catch(Exception exception) { }

                    return sb.toString();




thanks and regards,

Praveen T

To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Hubery Yao

    Hello Praveen,

    For Operation mapping, there are 3  styles: message mapping, JAVA mapping and XSL. Message mapping is common for most of PI projects. To be honest, so far , I never use JAVA mapping in PI project. Do you have some articles about JAVA mapping? How to use it. It refer to the NWDS or Eclipse?

    Thank you for your support in advance!

    Thanks & Best regards,


  2. Apu Das

    Hi Praveen,

    This is going to work when ur FCC is converted you file content in CC and it comes to MM.Them we can add this in OM to remove special character.

    What if our FCC cant work properly due to some special character which is violating xml norms and data cant even come upto MM.


    Apu Das

    1. Former Member Post author

      Hi Apu,

      Valid point but there is a work around.You simply remove the FCC and use the java mapping in operation mapping. It will not throw any error.

      Hope this answers your query.

      thanks and regards,

      Praveen T


Leave a Reply