Try using String.replace()
or String.replaceAll()
instead.
String my_new_str = my_str.replace("&", "&");
(Both replace all occurrences; replaceAll
allows use of regex.)
More Related Contents:
- Replace string \ with / android [duplicate]
- Replace a character specific number of times in String Java
- Search for keywords and replace them with their abbreviations [closed]
- String replace method is not replacing characters
- Replace a character at a specific index in a string?
- Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces
- Difference between String replace() and replaceAll()
- Java String replace not working [duplicate]
- Java Replacing multiple different substring in a string at once (or in the most efficient way)
- Strip Leading and Trailing Spaces From Java String
- Java Replace Line In Text File
- How can non-ASCII characters be removed from a string?
- How to replace case-insensitive literal substrings in Java
- Replace the last part of a string
- Find and replace words/lines in a file
- Can I replace groups in Java regex?
- Modifying existing file content in Java
- Why does String.replace not work? [duplicate]
- String replace a Backslash
- Java String.replace/replaceAll not working
- Most efficient way to use replace multiple words in a string [duplicate]
- How to replace first occurrence of string in Java
- What is the equivalent of Regex-replace-with-function-evaluation in Java 7?
- String.replaceAll is considerably slower than doing the job yourself
- Remove all occurrences of \ from string
- Replace Last Occurrence of a character in a string [duplicate]
- Hints for java.lang.String.replace problem? [duplicate]
- How can I write custom Exceptions?
- What’s an example of duck typing in Java?
- What optimizations can I expect from Dalvik and the Android toolchain?