title: IPv4/IPv6 network calculations and validation for Java?
body: <p>I am looking for a package that is similar to <a href="http://pear.php.net/package/Net_IPv4" rel="noreferrer">Net_IPv4</a> and <a href="http://pear.php.net/package/Net_IPv6" rel="noreferrer">Net_IPv6</a> but written for Java.  It needs to be able to do the following:</p>
  <ul>
  <li>Verify an address is valid (e.g. 127.0.0.1 is valid, 127.0.0.257 is not)</li>
  <li>Return if an address is contained within a subnet (e.g. 127.0.0.11 is in 127.0.0.0/28)</li>
  <li>Return the broadcast address for a given subnet (e.g. for 127.0.0.0/28 it's 127.0.0.15)</li>
  </ul>
  <p>It would be awesome if it could also:</p>
  <ul>
  <li>Return a list of addresses for a subnet in order</li>
  <li>Sort a list of addresses</li>
  </ul>
  <p>I could probably write a package to do all this, but if someone has already gone through the trouble and most likely has done a better job, I'm all about using that.  Anyone know of such a package or packages that could do all this?  We are expanding into IPv6, so it needs to work for both IPv4 and IPv6 if possible.</p>
  <p>I appreciate any help.</p>