Hi,
Will it be possible to get the file name alone with out the extension of file.
Example: KPPADF015-D00000-G0017700.xml
After processing the file at the output i want KPPADF015-D00000-G0017700_Text.txt
If i use (String)globalMap.get("tFileList_2_CURRENT_FILE")+"_Text"+".txt"
i am getting KPPADF015-D00000-G0017700.xml_Text.txt
I want the above output with out the file extension i.e,, KPPADF015-D00000-G0017700_Text.txt
For getting this i am using StringHandling.LEFT(((String)globalMap.get("tFileList_2_CURRENT_FILE")),25)+"_Text"+".txt"
The problem with the above approach is if the file name length is more than 25 letters it will not work. Is there any talend method to handle this dynamically with respect to file name alone with out extension.
Change the code to: ((String)globalMap.get("tFileList_2_CURRENT_FILE")).substring(0,((String)globalMap.get("tFileList_2_CURRENT_FILE")).indexOf("."))+"_Text.txt"
Hi
Try this expression:
(String)globalMap.get("tFileList_2_CURRENT_FILE").substring(0,
(String)globalMap.get("tFileList_2_CURRENT_FILE").indexOf(".")
)+"_Text.txt"
Hi, It shows the following error compilation problems: The method substring(int, String) is undefined for the type Object The method indexOf(String) is undefined for the type Object The method substring(int, String) is undefined for the type Object The method indexOf(String) is undefined for the type Object The method substring(int, String) is undefined for the type Object The method indexOf(String) is undefined for the type Object The method substring(int, String) is undefined for the type Object The method indexOf(String) is undefined for the type Object The method substring(int, String) is undefined for the type Object The method indexOf(String) is undefined for the type Object The method substring(int, String) is undefined for the type Object The method indexOf(String) is undefined for the type Object The method substring(int, String) is undefined for the type Object The method indexOf(String) is undefined for the type Object The method substring(int, String) is undefined for the type Object The method indexOf(String) is undefined for the type Object at gale.test_it_0_1.TEST_IT.tFileList_5Process(TEST_IT.java:563) at gale.test_it_0_1.TEST_IT.runJobInTOS(TEST_IT.java:3132) at gale.test_it_0_1.TEST_IT.main(TEST_IT.java:2982)
Change the code to: ((String)globalMap.get("tFileList_2_CURRENT_FILE")).substring(0,((String)globalMap.get("tFileList_2_CURRENT_FILE")).indexOf("."))+"_Text.txt"
Thanks a lot!!. It works perfectly.
Also i am able to acheive the same result using the following
((String)globalMap.get("tFileList_2_CURRENT_FILE")).replaceAll(".xml", "")
Either way it works!!!