Storing a range of ipAddresses?
Hi all,
I would like to know if there is a class that would store a range of IP's once the range is specified.
E.g.,
Say i allot the range 202.79.36.25 to 202.79.37.112.
Is there a class that could keep all ipAddresses lying between the above mentioned extreme IP's,
Thanx
[314 byte] By [
anamupotaa] at [2007-11-27 8:39:21]

# 2
Thank you so very much,However,my requirement is still not met.I queried if there is a class for generating all such ips and check whether a specified ip belonged to that range or not. Thanks again.
# 3
> Thank you so very much,
>
> However,my requirement is still not met.
> I queried if there is a class for generating all such
> ips and check whether a specified ip belonged to that
> range or not.
>
> Thanks again.
Here's an idea:
class IPRange {
private int[] start;
private int[] end;
public IPRange(int[] start, int[] end) {
this.start = start;
this.end = end;
}
public IPRange(String start, String end) {
this(asArray(start), asArray(end));
}
public boolean inRange(int[] ip) {
// check if 'ip' is in the range or not
}
public boolean inRange(String ip) {
return inRange(asArray(ip));
}
private static int[] asArray(String address) {
// convert 'address' to an array of int's
}
public String toString() {
return "IP range: "+java.util.Arrays.toString(start)+
" -> "+java.util.Arrays.toString(end);
}
}
Good luck.