Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am trying to read data from xml file and write them to Mysql db. In my db House_no field's data type is String(40). In xml file there are some house no values that longer than 40 and i want to cut all the values that are greater than 40.
so i try the code below in tMap but i got "java.lang.StringIndexOutOfBoundsException: String index out of range: 40 at java.lang.String.substring(Unknown Source)" error?
row4.house_no.length()>40 ?"" : row4.house_no.substring(0,40)
Do you have any idea what cause this error, or a better way to take 0-40 character without using tJavaRow.
thanks
iosman
___________________________
Try putting you ternary statement in the correct order and add a "null" check to it:
row4.house_no != null && row4.house_no.length() > 40 ? row4.house_no.substring(0,40) : row4.house_no