替换空格
程序员文章站
2022-03-08 17:24:18
...
public static String replaceSpace(String s) {
StringBuffer sb = new StringBuffer();
int n = s.length();
for (int i = 0; i < n; i++) {
char c = s.charAt(i);
if (c != ' ') {
sb.append(String.valueOf(c));
}
else {
sb.append("%20");
}
}
return sb.toString();
}