aspose file tools*
The moose likes Java in General and the fly likes Is it possible to remove all spaces from a String?(SOLVED) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is it possible to remove all spaces from a String?(SOLVED)" Watch "Is it possible to remove all spaces from a String?(SOLVED)" New topic
Author

Is it possible to remove all spaces from a String?(SOLVED)

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

No matter how many there are.

One Space should become OneSpace
Two More Spaces should become TwoMoreSpaces
etc


solution




-thanks henry


True wisdom is in knowing you know nothing - Socrates
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Sure... Take a look at the java.lang.String replace(), or replaceAll() methods.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Matt Kohanek wrote:
solution




Interesting solution. How about something much simpler? Like....



Henry
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

lol, well it just wouldnt feel like my code unless it was overly complicated and inefficient!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Is it possible to remove all spaces from a String?(SOLVED)