[resolved] Dynamic FileName in a TFileOutputRaw

One Star

[resolved] Dynamic FileName in a TFileOutputRaw

 Hi there;
I'm having difficulties setting a dynamic file name in a TFileOutputRaw component, something I have done in other components before.
So here is the job

Simple 4 step process

Read from an Queue,
First TjavaRow creates a file name in a context variable. Here the file name has been made to be a constant "singleout.txt"
Write the flow from the Queue to a TFilePutputRaw.
In the next step either it is Right or Wrong I use a Tjava to print the context variable used to transfer the name to prove that the context variable is actually set in the first TJavaRow.

If the tFileOutputRaw is set this way (above) it work fine.
If I set it up as below:

it does not, and I get the following output

Notice in the first and last highlighted text! The first shows the value of the context.currentOutPutFileName from within the first tJavaRow and the last highlighted text shows the same variable from either of the tJava components demonstrating that the context variable has been set and is accessible.
But if you look at the actual error (second yellow highlight) it should that the "constant" part of the path is seen  by the component but that the variable part (the context variable) is not interpreted at all? So I get an exception saying that I can't write to a directory directly implying I need a file name?
So why is the component not seeing the context variable in the filename?

Accepted Solutions
Four Stars

Re: [resolved] Dynamic FileName in a TFileOutputRaw

append this code at last.
+".text" file name must have any extension otherwise Talend will think it as directory.

All Replies
Four Stars

Re: [resolved] Dynamic FileName in a TFileOutputRaw

append this code at last.
+".text" file name must have any extension otherwise Talend will think it as directory.
One Star

Re: [resolved] Dynamic FileName in a TFileOutputRaw

gopi121 - your are right but I don't know why??
I added the +".text" to the filename in the component dialog and it worked
but what I don't understand is that the file name that is assigned to the context.currentOutPutFileName does contain an extension.
This is the line in the tJavaRow that I am using for testing


context.currentOutPutFileName = "singleout.txt";

why isn't this working?
One Star

Re: [resolved] Dynamic FileName in a TFileOutputRaw

Ok - I used a globalMap instead of context and that appeared to solve things as far as the file name.