title: Iterating through all IP addresses in a CIDR using java
body: <p>I want to know if there is any way to explode IPs of CIDR format. Along with exploding this code should take care of considering 'exclude' feature also.</p>
  
  <p>To be precise, I want something that takes something like 172.21.3.128/30(Inclusion list:172.21.3.128/30) and returns</p>
  
  <ul>
  <li>172.21.3.128</li>
  <li>172.21.3.129</li>
  <li>172.21.3.130</li>
  <li>172.21.3.131</li>
  </ul>
  
  <p>And if it has exclusion list as '172.21.3.130'(Inclusion list:172.21.3.128/30 &amp; exclusion list:172.21.3.130) then it should return </p>
  
  <ul>
  <li>172.21.3.128</li>
  <li>172.21.3.129</li>
  <li>172.21.3.131</li>
  </ul>
  
  <p>Currently I explode inclusion list &amp; keep in Set and explode exclusion list &amp; keep in set.And take the difference between two.Problem with this approach is I have to keep all exploded IPs in memory which might create problem(outofmemoryerror) if range is very big.</p>