Using temporary files
Occasionally, it is necessary to create intermediate files within a job that are only used during the lifetime of the job. This recipe shows how to use Talend temporary files.
Getting ready
Open the jo_cook_ch04_0030_temporaryFile
job.
How to do it...
The steps for using temporary files are as follows:
Open the
tCreateFileTemporary
component, and change the name tocustomerTemp_XXXX
.Select the options Remove file when execution is over, and Use temporary system directory.
Open the
tempCustomerOut
component, and change File Name to((String)globalMap.get("tCreateTemporaryFile_1_FILEPATH"))
.Repeat the steps for the
tempCustomerIn
component.Run the job, and you will see that data is written to and read from the temporary file.
How it works...
The tCreateTemporaryFile
component creates an empty file that is then available for writing in the main sub job. The name of the file is stored in the globalMap
variable tCreateTemporaryFile_1_FILEPATH
, which is referenced by both the output...