To pad a String in Talend Open Studio, use the StringUtils.rightPad, leftPad, center, or repeat functions. This example uses rightPad to add 0s to the end of a String if it's shorter than 8 characters
AAAAADDD -> AAAAADDD
CCCC -> CCCC0000
BBBB0000 -> BBBB00000
The following job sets up a list in a tForeach component of the test input data. A tIterateToFlow component applies a Commons Lang StringUtils.rightPad function. The result is output to a tLogRow. The results of the run and call to the StringUtils function are below.
|Application of rightPad() in a tIterateToFlow|
Commons Lang is a widely-used JAR available in Talend Open Studio. Several versions are installed with Talend 5. I use 2.6. The following shows the Basic Settings configuration for tLibraryLoad.
|Adding Commons Lang 2.6 to a Project|
I test Java expressions on a range of values from a tForEach rather than creating input files or records. Here is the configuration used for the tForeach.
|Input for Job in tForeach|