remove extra whitespace from string java code example
Example 1: how to remove all whitespace from string java
st = st.replaceAll("\\s+","")
Example 2: how to strip trailing spaces in java
String str = new String(" apples ");
str.trim(); // result is a nes string "apple"
Example 3: java remove double spaces
StringUtils.normalizeSpace(string);