public static void main(String args[]) {
System.out.println(stripGarbage("A good String"));
}
public static String stripGarbage(String s) {
String good = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
String result = ""; for (int i = 0; i < s.length(); i++) { if (good.indexOf(s.charAt(i)) >= 0)
result += s.charAt(i);
} return result;
}
}