谢谢你写的程序。
但我编译你写的IP代码没有通过。错误如下:
cannot resolve symbol
public IP(String ipString) throws NumberFormatException,ApplicatioException{
symbol:clas ApplicationException
location:class IP
cannot resolve symbol
if (ipSegment > 255 || ipSegment < 0) throw new ApplicationException("ip地址格式不正确!");
symbol:clas ApplicationException
location:class IP
cannot resolve symbol
throw new ApplicationException("ip地址格式不正确!");
symbol:clas ApplicationException
location:class IP
/**
* Created by IntelliJ IDEA.
* User: 黄海晏
* Date: 2004-8-11
* Time: 11:35:08
* To change this template use File | Settings | File Templates.
*/
public class IP {
private long ip;
private String[] segment;
public IP(long ip) {
this.ip = ip;
segment = new String[4];
for (int i = 3; i > -1; i--, ip >>= 8)
segment[i] = String.valueOf(ip - ((ip >> 8) << 8));
}
public IP(String ipString) throws NumberFormatException,ApplicationException {
segment = ipString.split("[.]");
if (segment.length == 4) {
ip = 0;
int ipSegment;
for (int i = 0; i < 4; i++) {
ip <<= 8;
ipSegment = Integer.parseInt(segment[i]);
if (ipSegment > 255 || ipSegment < 0) throw new ApplicationException("ip地址格式不正确!");
ip += ipSegment;
}
} else
throw new ApplicationException("ip地址格式不正确!");
}