Four Stars

Create dynamic file Name in mediation component cSplitter?

Hi

I am new to Talend. I want to create a dynamic name for writing the files. The flow is like cFile is consuming Four files from the directory then aggregate to one File on the basis of the file name and in cProcessor again  get the list of file name and folllowed by csplitter and then again cfile genertaes 4 files with source file name and the body.

here is the code for cProcessor:

     

 

List<String> fileList = new ArrayList<String>();
fileList = (List<String>)exchange.getProperty("CamelFileName");
System.out.println("After aggregation the fileName: "+
fileList);

List<String> listBody = new ArrayList<String>();
listBody = (List<String>)exchange.getProperty("body");
System.out.println("After aggregation the body: "+ listBody);


 exchange.setProperty("FileName",fileList);

Tags (1)
1 REPLY
Seven Stars

Re: Create dynamic file Name in mediation component cSplitter?

You should use a java bean and use a static list of string to store your filenames, then after the split, according to the message number (1,2,3 or 4) set it the name in the list (the correct header is CamelFileName)