code: public static String suppressWhiteSpace(String str) {
  	int len = str.length();
  	StringBuilder sb = new StringBuilder(len);
  	// boolean wasWS=false;
  
  	char c;
  	char buffer = 0;
  	for (int i = 0; i < len; i++) {
  	    c = str.charAt(i);
  	    if (c == '\n' || c == '\r') buffer = '\n';
  	    else if (isWhiteSpace(c)) {
  		if (buffer == 0) buffer = c;
  	    }
  	    else {
  		if (buffer != 0) {
  		    sb.append(buffer);
  		    buffer = 0;
  		}
  		sb.append(c);
  	    }
  	    // sb.append(c);
  	}
  	if (buffer != 0) sb.append(buffer);
  
  	return sb.toString();
      }
docs: remove all white spaces followed by whitespaces
  
  @param str string to translate
  @return translated string