Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a directory which contain several xml files and 1 file with (.tmp) extension.
I am trying to rename or replace the toTest.tmp to toTest.xml using a tfilelist and a tjava.
My tfilelist:
My tjava codes:
((String)globalMap.get("tFileList_3_CURRENT_FILE")).replace(((String)globalMap.get("tFileList_3_CURRENT_FILEEXTENSION")), "xml");
The job is ending without error but the file renaming is not taking place.
Can you suggest please?
I found a solution:
// File (or directory) with old name File oldfile = new File(((String)globalMap.get("tFileList_4_CURRENT_FILEPATH"))); // File (or directory) with new name File newfile = new File(((String)globalMap.get("tFileList_4_CURRENT_FILEPATH")).replace(((String)globalMap.get("tFileList_4_CURRENT_FILEEXTENSION")), "xml")); // Rename file (or directory) boolean success = oldfile.renameTo(newfile);
use tflieCopy
Normally, in my case, i cannot use tfilecopy.
Can you please advice how can i do this achieve this using tfilelist and tjava please?
Thank you.
You tJava seems incomplete and as mentionned by @fdenis this is not the best way as soon as you have a component to do what you expect.
I found a solution:
// File (or directory) with old name File oldfile = new File(((String)globalMap.get("tFileList_4_CURRENT_FILEPATH"))); // File (or directory) with new name File newfile = new File(((String)globalMap.get("tFileList_4_CURRENT_FILEPATH")).replace(((String)globalMap.get("tFileList_4_CURRENT_FILEEXTENSION")), "xml")); // Rename file (or directory) boolean success = oldfile.renameTo(newfile);
Hi @Rohit Aftab
i'm facing the same issue to change the file extension and i've tried this code in tjava. However, i'm getting error saying that "File cannot be resolved to a type"
Did you face the same error before or no? Do you have any idea about this?
Thank you
Please try importing "java.io.File"