如何删除 Java 中的第一个空格?
现在我正在使用这个:
if (str.charAt(0) == ' ') str = str.replace(" ", "");
只需使用str.trim()摆脱所有前导和尾随空格。