Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using tJava for rename of current filename

For one Talend job, I use the tJava component to replace the name of the current file

Code:

String currentFileName = ((String)globalMap.get("tFileList_1_CURRENT_FILE"));

String newCurrentFileName = null;

String pattern = ((String)globalMap.get("Stichtag"));

String replacement = "20181010";

 

if (currentFileName.contains(pattern)){

 

      newCurrentFileName = currentFileName.replaceAll(pattern, replacement);

      globalMap.put(((String)globalMap.get("tFileList_5_CURRENT_FILE")), newCurrentFileName);

     

}

But if I’ll execute this Job I get an exception:

Exception in component tJava_3

java.lang.NullPointerException

Do you have any ideas, what is wrong?

 

Thanks in advance

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

That is good news 🙂

 

Could you please mark the topic as resolved so that it will help our Talend community members?

 

Warm Regards,

 

Nikhil Thampi

View solution in original post

4 Replies
TRF
Champion II
Champion II

tJava component is executed before other components for the same subjob. So, depending on your job design (not shared) à npe exception may occurs.
May be tFileCopy should be enough for your case.
Anonymous
Not applicable
Author

Hi,

 

    In first step, you are using tFileList_1_CURRENT_FILE but in later step you are using tFileList_5_CURRENT_FILE.

 

    Could you please print and see the value in the variables to make sure that it is havign right values?

 

Warm Regards,

 

Nikhil Thampi

Anonymous
Not applicable
Author

Hello,

yes, you are right. It was written by mistake. Now it works fine.

 

Thank you very much.

Anonymous
Not applicable
Author

That is good news 🙂

 

Could you please mark the topic as resolved so that it will help our Talend community members?

 

Warm Regards,

 

Nikhil Thampi