Originally Posted by
Java Tip
The method below can be used to remove all the occurrences of a given text from a String.
public static String removeJunk(String string, String strToRemove)
{
return string.replaceAll(strToRemove, " ").trim();
}
The given method replaces the given text with a space, and also it trims the given string, which is not the intended behavior in your description. API documentation should be very clear on what it does, Also, this method you gave is not null safe and is it pretty useless on what it does. if it would provide better naming, functionality and a clear documentation, it might be useful.