Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我很难找到与 commons-lang StringUtils.removeEnd等效的番石榴。有没有这样的方法,还是我必须以某种方式使用 Joiner 和 Splitter?
我不认为 Guava 提供了这样的方法,但它是一个微不足道的单线:
s = s.endsWith(suffix) ? s.substring(0, s.length() - suffix.length()) : s;