title: How to convert IP address range to CIDR in Java?
body: <p>I am trying to convert the IP address range into the CIDR notation in Java. Can someone provide an example of how this can be achieved?</p>
  
  <p>I used the SubnetUtils for converting the CIDR to IP address range, but I can't figure out the other way round.</p>
  
  <p>For example: (using <a href="http://ip2cidr.com/" rel="noreferrer">http://ip2cidr.com/</a>)</p>
  
  <blockquote>
    <p><strong>Input 1:</strong> 5.10.64.0<br>
    <strong>Input 2:</strong> 5.10.127.255<br>
    <strong><em>Result:</em></strong> 5.10.64.0/18</p>
  </blockquote>
  
  <p>Thanks,
  Dhaval</p>