java string strip whitespace 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: remove space string java
a = a.replaceAll("\\s+", "");