It occured to me today the behavior of java String.split()
is very strange.
Actually I want to split a string "aa,bb,cc,dd,,,ee"
to array by .split(",")
that gives me a String array ["aa","bb","cc","dd","","","ee"]
of length 7.
But when I try to split a String "aa,bb,cc,dd,,,,"
to array this gives me a array of length 4 means only ["aa","bb","cc","dd"]
rejecting all next blank Strings.
I want a procedure that splits a String like "aa,bb,cc,dd,,,,"
to array ["aa","bb","cc","dd","","",""]
.
Is this possible with java.lang.String api? Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…