Are you sure that phoneNumber
is not equal to ""
?
You have to check that phoneNumber
have more chars than the csCountryCode.length()
.
String csAppendedCode = phoneNumber.length() > csCountryCode.length() ? phoneNumber.substring(0, csCountryCode.length()) : "";