Java examples for java.lang:String Search
Will return string without redundant spaces
//package com.java2s; public class Main { /** Will return string without redundant spaces, * that means string 'str' will be trimmed * and all 'groups-of-more-than-one-spaces'(if any) * will be replaced by exactly one space. * @param str string where you want to remove redundant spaces * @return trimmed string with only space between each group of chars(if any) *//*from w ww . j ava 2 s . com*/ public static String removeRedundantSpaces(String str) { return str.trim().replaceAll("\\s+", ""); } }