on 11-21-2008 2:02 PM
Hi,
I have an XML message as String. I need to replace
<?xml version="1.0" encoding="UTF-8"?>
with space
blank. How to do that on Java 1.4.2
Hello,
have a look at [this|http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#replaceFirst(java.lang.String,%20java.lang.String)] method
regrads franz
...close thread if message is answered
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
well I did it with this part of code:
public static String replaceStr(String source, String pattern, String replace) {
if (source != null) {
final int len = pattern.length();
StringBuffer sb = new StringBuffer();
int found = -1;
int start = 0;
while ((found = source.indexOf(pattern, start)) != -1) {
sb.append(source.substring(start, found));
sb.append(replace);
start = found + len;
}
sb.append(source.substring(start));
return sb.toString();
} else
return "";
}
But there can be problem replacing in huge messages? How to speedUp something like that?
User | Count |
---|---|
71 | |
26 | |
10 | |
9 | |
7 | |
6 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.