wood burning stoves 2.0*
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: 38107
    
  22
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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: which string function to remove whitespace between two strings
 
Similar Threads
Removing specific character from the given String
How to trim spaces between characters of string using javascript
Remove unwanted chars (new line,tab) in java
Referenec passing
trim ()