java how to get rid of spaces at the start of string without replace code example Example: java 8 remove spaces from string a.replaceAll("\\s+","");