开发者

How to remove white space characters in between the string?

For example, I want to convert the string test123 test124 test125 to

test123+""+test124+""+test125 or test123test开发者_如何学C124test125.

How to achieve this?

Thanks


String output = inputText.replaceAll("\\s+",""); 


use String.replace():

"test123 test124 test125".replace(" ", "");


Use String result = yourString.replace(" ","");


You can use the replace method of the string like

str.replace(" ","");


You can also try using String Tokeniser, simplest way is,

String s = "test123 test124 test125";        
StringTokenizer st = new StringTokenizer( s, " " );
while(st.hasMoreTokens())
{
    System.out.print(st.nextToken());
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜