The method 'deleteCharAt()' was made available starting with JDK 1.2, so if
you're still on JDK 1.1 then this code won't work :-(
-----Original Message-----
From: Ajit Bhingarkar [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 21, 2000 12:42 PM
To: [EMAIL PROTECTED]
Subject: Re: Replace " "
You can use:
String removeAllSpaces(String s)
{
StringBuffer sf = new StringBuffer(s);
int max = sf.length();
for(int i=0; i<max; i++)
{
if(sf.charAt(i)==' ')
{
sf = sf.deleteCharAt(i);
max = sf.length();
}
}
return sf.toString();
}
"Bolt, Dave" wrote:
>
> You could use StringTokenizer where the delimiter is a space and simply
keep
> only the elements.
>
> Dave Bolt
> ATSC/SPAWAR ASAT Team
> Bolt's Law of Bandwidth - There is always plenty of network bandwidth,
just
> none for you.
>
> -----Original Message-----
> From: Daryani Santosh [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 21, 2000 2:32 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Replace " "
>
> trim() will remove any leading or trailing spaces , but does not remove
> spaces
> within the string if any. AFIAK , breaking the string and using concat
seems
> to
> be the best known solution , you could consider using a stringbuffer and
> appending the portions of the string without spaces , but even that is not
> any
> better than breaking the string and doing a concat
>
> Santosh
>
> Kevin Citron <[EMAIL PROTECTED]> on 09/21/2000 02:01:46 PM
>
> Please respond to A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>
> To: [EMAIL PROTECTED]
> cc: (bcc: Santosh Daryani/IT/Aon Consulting)
>
> Subject: Re: Replace " "
>
> try Str.trim();
>
> -----Original Message-----
> From: sumit shah [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 21, 2000 10:59 AM
> To: [EMAIL PROTECTED]
> Subject: Replace " "
>
> hi,
> is there any method of the String class which will allow me to get rid
of
> the blank spaces in a string.
> i tried Str.replace(' ', '') but jvm does not agree with the 2nd
argument
> saying incompatible type. Is there any direct method other than breaking
the
> string into substring and then concat() it. or if something that i can put
> instead of ''.
>
> thanks,
> sumit.
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets