• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to replace a small string from a big StringBuffer  RSS feed

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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")
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!