This snippet will show how to strip spaces from a string using a regex.
Straight up Java
@Test
public void strip_spaces() {
String sampleString = "Remove space whitespace";
String removeSpaces = sampleString.replaceAll("\s", "");
assertEquals("Removespacewhitespace", removeSpaces);
}