java 8 string clear white spaces code example Example: remove space string java a = a.replaceAll("\\s+", "");