This example will show how to remove all whitespace from a string using java, guava and apache commons. In the snippets below we will use various user groups names throughout the midwest.
Straight up Java
String.replaceAll
This snippet show how to replace all whitespaces using core java jdk String.replaceAll.
Regex
This snippet will remove all whitespace from a string using a regex expression.
Google Guava
This snippet will remove blank characters from a string using guava Charmatcher. Calling Charmatcher removeFrom method will remove all non matching chars or spaces.
Apache Commons
This snippet will show how to remove empty characters in a string using StringUtils.deleteWhitespace.