aspose file tools*
The moose likes Beginning Java and the fly likes inserting into strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inserting into strings" Watch "inserting into strings" New topic
Author

inserting into strings

kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
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
Michael Fitzmaurice
Ranch Hand

Joined: Aug 22, 2001
Posts: 168
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


"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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

Joined: Aug 24, 2001
Posts: 85
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.
 
subject: inserting into strings