Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Comparing IP addresses

843790Aug 7 2009 — edited Aug 21 2009
Hi everyone!

I have an IP address which belongs to the type InetAddress and I would like to check if it is within the range: 192.168.1.2 -> 192.168.1.101. I was thinking about using methods like greater than and smaller than but I can't find any for this class. Moreover, how I should define 192.168.1.2 and the other one? As String and then convert to another type? And the last thing: the IP address I have to compared is got using the method getInetAddresses(), which means that an annoying slash "/" is the first character of the address: (e.g. if I print it: /192.168.1.22) which probabaly makes it more difficult to be compared.

Can you help me please??

Many thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 18 2009
Added on Aug 7 2009
4 comments
678 views