是否有一种方便的方法可以从 Java 字符串中去除任何前导或尾随空格?
类似:
String myString = " keep this ";
String stripppedString = myString.strip();
System.out.println("no spaces:" + strippedString);
结果:
no spaces:keep this
myString.replace("","")
将替换 keep 和 this 之间的空格。
最佳答案
关于java - 从 Java 字符串中去除前导和尾随空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6652687/