I want to be able to return true/false depending on an IP being in range of two other IPs.
For instance:
ip 192.200.3.0
range from 192.200.0.0
range to 192.255.0.0
should result to true.
Other examples:
assert 192.200.1.0 == true
assert 192.199.1.1 == false
assert 197.200.1.0 == false
The easiest way to check the range is probably to convert the IP addresses to 32-bit integers and then just compare the integers.
Rather than
InetAddress.getByName()
, you may want to look at the Guava library which has an InetAddresses helper class that avoids the possibility of DNS lookups.