public static Long fomartIpaddress(String ipaddress) throws Exception{
StringBuffer sb = new StringBuffer();
//为什么用"."格式化会报错呢?改为"\\."就好了,请问这是为什么呢?
String[] strList = ipaddress.split(new String("\\."));
for(String str:strList){
sb.append(str);
}
return Long.parseLong(sb.toString());
} |
|