

Can some one check the java code and please suggest the changes to get the correct output,
Mapping results are not as accepted(Multiple xml files)
tried the below java code from the blog but the records are separated but still in the same xml .
https://answers.sap.com/questions/12920191/how-to-split-single-xml-file-contains-two-separate.html
public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException { getTrace().addInfo("JAVA Mapping Called"); String inData = convertStreamToString(arg0.getInputPayload().getInputStream()); String outData = ""; String[] out = inData.split("</Orders>"); String xUTF = "<Orders>"; // inData = inData.replace(xUTF,"<?xml version=\"1.0\" encoding=\"utf-8\"?><Orders>"); inData = inData.replace(xUTF,""); for (String s: out) { try { inData = s.concat("</Orders></ns0:MT_Orders"); arg1.getOutputPayload().getOutputStream().write(inData.getBytes()); } catch(Exception e) { e.toString(); } } } public String convertStreamToString(InputStream in) { StringBuffer sb = new StringBuffer(); try { InputStreamReader isr = new InputStreamReader(in); Reader reader = new BufferedReader(isr); int ch; while((ch = in.read()) > -1) { sb.append((char)ch);} reader.close(); } catch(Exception exception) { exception.toString(); } return sb.toString(); }