开发者

using delimiter but not delete spaces

I am writing a program where I wa开发者_如何学Gont to split a string separated by comma. My problem is a user can pass or input the string to the program like this:

   Hello,,hey,123 

So, is there a way that I can add a space between the hello and hey before I append it to a arraylist. Also my delimiter is ignoring the double ,, and just going to the next word why is that ?


String s = "Hello,,hey,123";
String[] tokens = s.split(",", -1);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜