Defanging an IP Address
没啥解释的.
class Solution {
public String defangIPaddr(String address) {
StringBuffer sb = new StringBuffer();
for(int i = 0 ; i < address.length(); i++) {
if(address.charAt(i) == '.') {
sb.append("[");
sb.append(".");
sb.append("]");
}
else {
sb.append(address.charAt(i));
}
}
return sb.toString();
}
}