java remove double spaces

Java
StringUtils.normalizeSpace(string);
Source

Also in Java: