日期:2014-05-20 浏览次数:20758 次
package com.zyc.aaa;
public class Test {
public static void main(String[] args) {
String src = "6sabcsssfsfs33";
char[] arr = new char[] { 'a', 'b', '3' };
System.out.println(removeChars(src, arr));
}
static String removeChars(String src, char[] arr) {
StringBuffer sb = new StringBuffer();
boolean[] flags = new boolean[256];
for (char c : arr) {
flags[c] = true;
}
for (char c : src.toCharArray()) {
if (!flags[c]) {
sb.append(c);
}
}
return sb.toString();
}
}