public static void main(String... aArgs) throws IOException{
String s = "\2.\1.domain.com";
System.out.println(filterCtrlChars(s));
}
public static String filterCtrlChars(String source){
StringBuffer sf = new StringBuffer();
for (char c : source.toCharArray()){
if (Character.isISOControl(c)){
sf.append("\\")
.append(Integer.toOctalString(c));
}else{
sf.append(c);
}
}
return sf.toString();
}
------解决方案--------------------