aspose file tools
The moose likes Java in General and the fly likes same stuff Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "same stuff" Watch "same stuff" New topic
Author

same stuff

vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
okay thanks for ur previous posts, okay let us take a example if i have say
String lo = "advr$o&" ;
i want to replace $ by string "ror" and & by "roro" how can i do it thro String buffer as u said . might be next time i get the value of lo to be "$ghg& " so the position if special characters is not fixed , can u give a snippet for this.


SCJP, SCWD <br />A farmer learns more from a bad harvest than a good one.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
vivek
Check out the StringBuffer replace method. What you need to do is iterate over the Stringbuffer to find the characters you're looking for then do a replace. the trick is to increase your counter so that you go beyond the String you just inserted or you'll replace the characters in that too if they match what you're looking for. If you want that behavior then you dont need to increment i except by 1 at the end of the while loop.
Check out this code:

hope that helps


Dave
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: same stuff
 
Similar Threads
String literals
What's my member number ?
String a-go-go
strings
Hi