Reverse a String

One Star

Reverse a String

Anyone know the best way in Talend to reverse order a string ?
i.e.
ABCD to DCBA
Thanks
One Star

Re: Reverse a String

I use this routine
/**
* reverseIt() Reverses a string.
*
* {talendTypes} String
*
* {Category} Ncl_routines
*
* {param} string ("fred") input: the string to be reversed
*
* {example} reverseIt("fred") # derf
*
*/
public static String reverseIt(String source) {
int i, len = source.length();
StringBuffer dest = new StringBuffer(len);
for (i = (len - 1); i >= 0; i--)
dest.append(source.charAt(i));
return dest.toString();
}
One Star

Re: Reverse a String

Thanks, I've got this routine but since I'm new to talend I just need a clue on how to apply it and encode it in a tmap function on an incoming string.
One Star

Re: Reverse a String

Under Code create new routine and add the code then use it as you would Talend routines.

What’s New for Talend Spring ’19

Join us live for a sneak peek!

Sign up now

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download