Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] How to creating a unique file name for temporary files

I would like to know if someone knows how to create a filename in a directory that is guaranteed to be unique.
I have several different jobs that use tHashOutput components extensively. In order to handle large data sets, I would like to use temporary files instead of tHash components to preserve memory. The problem I am concerned about is what will happen if two different jobs are running concurrently and both attempt to create a temporary file with the same name. I would like to be able to create a file on the fly without worrying about whether it will conflict with any other jobs.
Has anyone encountered this same issue?
Thanks.
Labels (2)
1 Solution

Accepted Solutions
c0utta
Creator
Creator

I use the tCreateTemporaryFile component using System.getenv("TMP") as the Directory setting and then use the FILEPATH global variable to get the full path name.
The great thing is the file is then deleted automatically once the job finishes.

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Use variable jobName and timestamp:
jobName+TalendDate.formatDate("yyyyMMddHHmmss",TalendDate.getCurrentDate())+".log"
c0utta
Creator
Creator

I use the tCreateTemporaryFile component using System.getenv("TMP") as the Directory setting and then use the FILEPATH global variable to get the full path name.
The great thing is the file is then deleted automatically once the job finishes.
Anonymous
Not applicable
Author

Thanks!