Delete whitespaces from a String in Java with Apache Commons StringUtils class

This example shows how to delete all whitespaces in a String using the Apache Commons StringUtils class which is very easy as it comes with a handy deleteWhitespace() method. It doesn’t matter where in the value the whitespaces are located, everyone will be removed. To the method you send the String that is to be stripped of whitespaces and from it you get the new String without whitespaces:

Below you can see the result from the code above:

Search for more Java info on this site here:
Custom Search

Please type any questions here.