How to replace a small string from a big StringBuffer
Rohit Kumar
Ranch Hand
Joined: Sep 20, 2007
Posts: 53
posted
0
Hi,
I have a big string buffer, which has data in xml format. I wann to change a particular small stings from the String buffer. I don't think String's find/replace policy, or even xml parsing is good option here.
What would be best option in this senarieo?
Thnaks.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35224
7
posted
0
I don't think String's find/replace policy, or even xml parsing is good option here.
What do you mean by "policy"? If you're certain that the text occurs only in within text elements (and not in attribute or element names), then find/replace should work fine.
You should prob'ly use a DOM library if you can find one. There are a variety of them that are tailored toward various uses.
If you are absolutely certain that the string you want to change will not be part of the markup, you could certainly use StringBuilder/StringBuffer. (i.e. "Frankensteen" => "Frankenstein")
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);