Here you can find the source of normalizeWhiteSpace(String input)
public static String normalizeWhiteSpace(String input)
//package com.java2s; //License from project: LGPL public class Main { public static String normalizeWhiteSpace(String input) { return input.replaceAll("\\s+", " ").replaceAll("([^\\w])\\s+", "$1"); }/*from w w w . ja va 2 s . co m*/ }