• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inserting into strings

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a string that contains spaces in it. Now I want to 'replace' those spaces with %20. How do I go about doing that? Also, the number of spaces in the string can vary. TIA.
Kevin
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kevin
Have a look at:
http://www.javaranch.com/ubb/Forum33/HTML/004104.html
Hope this helps
Michael

------------------
"One good thing about music - when it hits, you feel no pain"
Bob Marley
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not entirely what you asked for, but if you're trying to do what I think you're trying to do have a look at java.net.URLEncoder.
- Peter
 
kevin schmidt
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I managed to figure it out yesterday, and what the Java.net.URLEncoder does is... well... I'm not too sure, but the encoding scheme of it is not the same as if you look up "URL Encoding" on google or something. What I was looking for was to replace spaces with "%20", but when using the java encoder class, it gave me a "+" and also encoded a lot more than I wanted to. I just wrote my own routine and it does exactly what I wanted it to. Thanks though.
kevin
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic