java remove blank from string but not between words code example Example: java 8 remove spaces from string a.replaceAll("\\s+","");