Limit a String in Java

Hi everybody, 

I am trying to limit a string column, to a certain length, lets say 50. First I looked at the "String Manipulator node", but I could not find a function for that.  Then I tried with the Java Snippet with the following code, but I just get missing values, "?". 

Any help will be highly appreciated. 

if (c_input.length() > 50) {
    c_input = c_input.substring(0,50);
}

 

 

Hi,

it seems as if you're overwriting your input variable instead of an output variable. Both are separated from each other, even if they point to the same column. I suppose you added the output column in the "Output"-Panel - then there should be a different name in the last field, normaly it's something like "out_input". Accordingly, I would expect something like this to work:

out_input = c_input;

if (c_input.length() > 50) {
    out_input = c_input.substring(0,50);
}

 

What's wrong with the "substr(str, start, length)" function from the String Manipulation node?

Thank you 

Thank you I was not aware of that function

Best regards