aspose file tools*
The moose likes Java in General and the fly likes which string function to remove whitespace between two strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "which string function to remove whitespace between two strings" Watch "which string function to remove whitespace between two strings" New topic
Author

which string function to remove whitespace between two strings

pavithra murthy
Ranch Hand

Joined: Feb 06, 2009
Posts: 56
hello ,

i want to remove spaces between 2 strings .

the trim function in string will remove only leading and trailing whitespaces.

but is there any string function in java such that the for example

str=" javahorn forum"

i want to remove the whitespace between javahorn and forum such that it displays as

str=" javahornforum"
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39832
    
  28
Look for the replace and replaceAll methods. You may require an understanding of refular expressions.
sridhar vedhanabatla
Greenhorn

Joined: Feb 21, 2007
Posts: 12
Using regular expressions might help you in long term.

But for quick getting quick results without spending too much resources in writing good regexes you can alternatively try Apache string util api at http://commons.apache.org/lang/apidocs/org/apache/commons/lang/StringUtils.html for several string processing functions.

 
jQuery in Action, 2nd edition
 
subject: which string function to remove whitespace between two strings