Using Java, how can I replace all consecutive white spaces with a single space, in an elegant and simple way?
I am aware of str.replaceAll("\\s+", " "); but this replaces \n and other things too. I only want to replace multiple one after another with a single .