Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8950

Re: Adding Header in Appended File

$
0
0

Hi Bhaskar,

                   Try this mapping for including both header and footer. You can add and remove lines of code to include the footer or remove it.

 

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class RemoveExtraElement  extends AbstractTransformation{  /**  * @param args  * @throws FileNotFoundException   * @throws StreamTransformationException   */  @Override  public void transform(TransformationInput arg0, TransformationOutput arg1)  throws StreamTransformationException {  // TODO Auto-generated method stub  execute(arg0.getInputPayload().getInputStream(),arg1.getOutputPayload().getOutputStream());  }    public void execute(InputStream in, OutputStream out) throws StreamTransformationException    {    try    {    StringBuilder s = new StringBuilder();       byte[] b=new byte[in.available()];       if(in.read(b) >= 0) {        s = new StringBuilder(s.toString()+new String(b));       }              String header="\"NOTACTIVE\",\"STUD_ID\",\"FNAME\",\"LNAME\",\"MI\",\"GENDER\",\"JP_ID\",\"JP_DESC\",\"JOB_TITLE\",\"ORG_ID\"!##!\n";       s= new StringBuilder(s.insert(0,header));       String footer="\nTB TA TC 2015/12/01 2015/12/31 3000";       s=s.append(footer);       System.out.println(s);       out.write(s.toString().getBytes("UTF-8"));       in.close();       out.close();    }        catch(Exception e)    {    e.printStackTrace();    throw new StreamTransformationException(e.getMessage());    }    }
}

Regards

Anupam


Viewing all articles
Browse latest Browse all 8950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>