How to remove characters from a String in Java



This example shows how to easily remove characters from a String using the StringUtils class in the Apache Commons Lang library.
The StringUtils class in the library has two overloaded methods for remove().
The first takes a char as parameter specifying what character to remove. All characters of that type is removed in the returned String.
The second overloaded version takes a sequence of characters (a String) as parameter along with the value to replace in.
The code below demonstrates this:

The output from the code above is:







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


Please type any questions here.