aspose file tools*
The moose likes Beginning Java and the fly likes How to wipe off the whitespace in the String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to wipe off the whitespace in the String" Watch "How to wipe off the whitespace in the String" New topic
Author

How to wipe off the whitespace in the String

qingwu wang
Ranch Hand

Joined: Feb 19, 2003
Posts: 147
Hello Everybody!
if there is one function that can wipe off white space in the jdk.if not,can anyone give me some advice?Thanks a lot


Thanks...qingwu<br />When I open my eyes,I see your pretty face.
Wendal Park
Ranch Hand

Joined: Aug 28, 2001
Posts: 39
Just call the trim() method.
For Example:
String str = "Hello World    ";
str = str.trim() // would give "Hello World"
if you want to remove whitespaces within a string, one way of doing it is:

Wendal
[ June 24, 2003: Message edited by: Wendal Park ]

MSc, BSc, SCJP 1.4<br /> <img src="graemlins/banghead.gif" border="0" alt="[banghead]" /> SCBCD
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hello
if you want to replace all there is also a function in 1.4....
replaceAll(String regex, String replacement)
Replaces each substring of this string that matches the given regular expression with the given replacement.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to wipe off the whitespace in the String