how to split the string like "x~y~z~~~~~" with delimiter ~ ,we have to split this as 7 elements. but while processing with string.split("~") method it gives 3 strings only
how to split the string like x~y~z~~~~~ with delimiter ~ ,we have to split
Share
Try below :
refer Javadoc for the split method taking two arguments for details.
When calling String.split(String), it calls String.split(String, 0) and that discards trailing empty strings (as the docs say it), when calling String.split(String, n) with n < 0 it won’t discard anything.