java中删除字符串的头尾空白符。

trim() 方法

String Str = new String("    abc   ");
System.out.println( Str );
System.out.println( Str.trim() );

输出结果:
   abc   
abc//使用trim函数后首尾的空白符被删去
发布了204 篇原创文章 · 获赞 152 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/z2431435/article/details/105442455
今日推荐