A common Job using tJava is generally composed of:
-
a tFileInputDelimited component to read data from a
text file,
-
a tLogRow component to print data in the
console,
-
a tJava component to retrieve the total number of
records processed.
Procedure
-
In the Palette, drag and drop a tFileInputDelimited , a
tLogRow and a tJava component
onto the workspace.
-
Connect tFileInputDelimited to
tJava using a Trigger >
OnSubjobOk link.
-
Set the Basic settings of the tFileInputDelimited
component.
-
Double-click on tFileInputDelimited to display its
Basic settings. In the file
name/steam field, add the source data file path
"C:/person.txt".
-
This file includes the following data:
1;Shong
2;Elisa
3;Sabrina
-
Click the Edit Schema button and set the two-column
schema.
-
Double-click on tjava to display its Basic
settings view and add the following code in the
Code area:
int nb_line=(Integer)globalMap.get("tFileInputDelimited_1_NB_LINE");
System.out.println("The total number of records are read from the text file is: " +nb_line);
-
Execute the Job by pressing F6.
Results
The actual records from the input file are printed into the console
natively. In addition, due to the use of the tJava component, the
number of records also displays onto the console.