check is middle string have only one space code example Example: java remove double spaces StringUtils.normalizeSpace(string);