<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic cProcessor java code for adding character at end of specific line in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/cProcessor-java-code-for-adding-character-at-end-of-specific/m-p/2273158#M50219</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am working on a talend map. I am using cProcessor to change the data received.&lt;/P&gt;&lt;P&gt;The example file is like shown below. My requirement is if the line starts with PR then append XYZ at the end of line.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Input file&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PA;AB;2020;1;2&lt;/P&gt;&lt;P&gt;PR;DD;2020;3;4&lt;/P&gt;&lt;P&gt;PB;AB;2020;5;6&lt;/P&gt;&lt;P&gt;PR;DD;2020;7;2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Output file&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PA;AB;2020;1;2&lt;/P&gt;&lt;P&gt;PR;DD;2020;3;4XYZ&amp;nbsp;&lt;/P&gt;&lt;P&gt;PB;AB;2020;5;6&lt;/P&gt;&lt;P&gt;PR;DD;2020;7;2XYZ&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please let me know how we can achieve it using cProcessor.&lt;/P&gt;&lt;P&gt;I am reading whole file by below java code -&lt;/P&gt;&lt;P&gt;String body = exchange.getIn().getBody(String.class);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to add XYZ where line starts with PR in string body ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 03:26:15 GMT</pubDate>
    <dc:creator>VijayTalend</dc:creator>
    <dc:date>2024-11-16T03:26:15Z</dc:date>
    <item>
      <title>cProcessor java code for adding character at end of specific line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/cProcessor-java-code-for-adding-character-at-end-of-specific/m-p/2273158#M50219</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am working on a talend map. I am using cProcessor to change the data received.&lt;/P&gt;&lt;P&gt;The example file is like shown below. My requirement is if the line starts with PR then append XYZ at the end of line.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Input file&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PA;AB;2020;1;2&lt;/P&gt;&lt;P&gt;PR;DD;2020;3;4&lt;/P&gt;&lt;P&gt;PB;AB;2020;5;6&lt;/P&gt;&lt;P&gt;PR;DD;2020;7;2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Output file&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;PA;AB;2020;1;2&lt;/P&gt;&lt;P&gt;PR;DD;2020;3;4XYZ&amp;nbsp;&lt;/P&gt;&lt;P&gt;PB;AB;2020;5;6&lt;/P&gt;&lt;P&gt;PR;DD;2020;7;2XYZ&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please let me know how we can achieve it using cProcessor.&lt;/P&gt;&lt;P&gt;I am reading whole file by below java code -&lt;/P&gt;&lt;P&gt;String body = exchange.getIn().getBody(String.class);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to add XYZ where line starts with PR in string body ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 03:26:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/cProcessor-java-code-for-adding-character-at-end-of-specific/m-p/2273158#M50219</guid>
      <dc:creator>VijayTalend</dc:creator>
      <dc:date>2024-11-16T03:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: cProcessor java code for adding character at end of specific line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/cProcessor-java-code-for-adding-character-at-end-of-specific/m-p/2273159#M50220</link>
      <description>&lt;P&gt;This is a quick bit of code I have put together starting from after you have retrieved your body message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;String lines[] = body.split("(\r\n|\n)");
String outputBody = "";

for(int i=0; i&amp;lt;lines.length;i++){
	
	if(lines[i].startsWith("PR")){
		outputBody = outputBody+lines[i]+"XYZ\r\n";
	}else{
		outputBody = outputBody+lines[i]+"\r\n";	
	}	
	
}

System.out.println(outputBody);&lt;/PRE&gt;
&lt;P&gt;I've assumed that you data has a carriage return and line feed (\r\n) separating the rows. You may need to test and tweak this. All you need to do after this is to add it back to the In Message of the&amp;nbsp;Exchange.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know how it goes&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2020 18:03:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/cProcessor-java-code-for-adding-character-at-end-of-specific/m-p/2273159#M50220</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-01T18:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: cProcessor java code for adding character at end of specific line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/cProcessor-java-code-for-adding-character-at-end-of-specific/m-p/2273160#M50221</link>
      <description>&lt;P&gt;Thanks for the Java code. It worked like a charm &lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 15:18:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/cProcessor-java-code-for-adding-character-at-end-of-specific/m-p/2273160#M50221</guid>
      <dc:creator>VijayTalend</dc:creator>
      <dc:date>2020-02-02T15:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: cProcessor java code for adding character at end of specific line</title>
      <link>https://community.qlik.com/t5/Talend-Studio/cProcessor-java-code-for-adding-character-at-end-of-specific/m-p/2273161#M50222</link>
      <description>&lt;P&gt;Not a problem, I'm glad it helped &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Feb 2020 15:22:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/cProcessor-java-code-for-adding-character-at-end-of-specific/m-p/2273161#M50222</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-02T15:22:04Z</dc:date>
    </item>
  </channel>
</rss>

