<?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 How to make column names dynamic in tJavaFlex in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-make-column-names-dynamic-in-tJavaFlex/m-p/2283795#M57625</link>
    <description>&lt;P&gt;Hi&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have used tOracle input to extract data from Oracle DB.Then used tJavaFlex to split the data into multiple chunks of bytes.&lt;/P&gt; 
&lt;P&gt;Used the following code in Start and Main code.I have used the option Dynamic in Edit schema of the tJava Fex to get the column lists of the tables on the fly automatically&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Start Code&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Integer iterator = 1;&lt;BR /&gt;Integer ByteCount = 0;&lt;BR /&gt;FileOutputStream fos = new&lt;BR /&gt;FileOutputStream(context.TgtFilePath+"TargetFile_"+iterator+".csv");&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Main Code&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;STRONG&gt;String tmpReadLine= row1.FirstName+","+&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;row1.LastName+","+&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;row1.Age+","+&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;row1.City+","+&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;row1.State+"\n"; //Read input fields&lt;/STRONG&gt;&lt;/P&gt; 
&lt;P&gt;byte[] contentInBytes = tmpReadLine.getBytes();//Convert them to Byte array&lt;/P&gt; 
&lt;P&gt;ByteCount=ByteCount+contentInBytes.length; // Summation of line bytes read&lt;/P&gt; 
&lt;P&gt;if ( ByteCount &amp;gt; context.SplitByte ) {&lt;BR /&gt;// Check if bytes read hasn't crossed the threshold&lt;BR /&gt;ByteCount = 0;&lt;/P&gt; 
&lt;P&gt;fos.flush();&lt;BR /&gt;fos.close();&lt;BR /&gt;iterator = iterator+ 1;&lt;/P&gt; 
&lt;P&gt;// Threshold crossed write to new file&lt;BR /&gt;fos = new&lt;BR /&gt;FileOutputStream(context.TgtFilePath+"TargetFile_"+iterator+".csv");&lt;BR /&gt;} else {&lt;BR /&gt;fos.write(contentInBytes); // else write to same file&lt;BR /&gt;}&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Now I do not want to hard-code the column names in the Main code portion of the tJavaFlex(as given in bold above).&lt;/P&gt; 
&lt;P&gt;What is the alternative solution to make the column names dynamic because I want to use the same Talend job for multiple data extraction&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 02:46:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-11-16T02:46:56Z</dc:date>
    <item>
      <title>How to make column names dynamic in tJavaFlex</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-make-column-names-dynamic-in-tJavaFlex/m-p/2283795#M57625</link>
      <description>&lt;P&gt;Hi&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have used tOracle input to extract data from Oracle DB.Then used tJavaFlex to split the data into multiple chunks of bytes.&lt;/P&gt; 
&lt;P&gt;Used the following code in Start and Main code.I have used the option Dynamic in Edit schema of the tJava Fex to get the column lists of the tables on the fly automatically&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Start Code&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Integer iterator = 1;&lt;BR /&gt;Integer ByteCount = 0;&lt;BR /&gt;FileOutputStream fos = new&lt;BR /&gt;FileOutputStream(context.TgtFilePath+"TargetFile_"+iterator+".csv");&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Main Code&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;STRONG&gt;String tmpReadLine= row1.FirstName+","+&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;row1.LastName+","+&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;row1.Age+","+&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;row1.City+","+&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;row1.State+"\n"; //Read input fields&lt;/STRONG&gt;&lt;/P&gt; 
&lt;P&gt;byte[] contentInBytes = tmpReadLine.getBytes();//Convert them to Byte array&lt;/P&gt; 
&lt;P&gt;ByteCount=ByteCount+contentInBytes.length; // Summation of line bytes read&lt;/P&gt; 
&lt;P&gt;if ( ByteCount &amp;gt; context.SplitByte ) {&lt;BR /&gt;// Check if bytes read hasn't crossed the threshold&lt;BR /&gt;ByteCount = 0;&lt;/P&gt; 
&lt;P&gt;fos.flush();&lt;BR /&gt;fos.close();&lt;BR /&gt;iterator = iterator+ 1;&lt;/P&gt; 
&lt;P&gt;// Threshold crossed write to new file&lt;BR /&gt;fos = new&lt;BR /&gt;FileOutputStream(context.TgtFilePath+"TargetFile_"+iterator+".csv");&lt;BR /&gt;} else {&lt;BR /&gt;fos.write(contentInBytes); // else write to same file&lt;BR /&gt;}&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Now I do not want to hard-code the column names in the Main code portion of the tJavaFlex(as given in bold above).&lt;/P&gt; 
&lt;P&gt;What is the alternative solution to make the column names dynamic because I want to use the same Talend job for multiple data extraction&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 02:46:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-make-column-names-dynamic-in-tJavaFlex/m-p/2283795#M57625</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T02:46:56Z</dc:date>
    </item>
  </channel>
</rss>

