// Can cover 127 bits
public static String getIp6FromRange(String ip6Range) {
String[] ips = ip6Range.split("-");
String startIp = ips[0];
IPv6Address start = IPv6Address.fromString(startIp);
BigInteger gap = countIp6InRange(ip6Range);
BigInteger next = new BigInteger(gap.bitLength(), _rand);
while (next.compareTo(gap) >= 0) {
next = new BigInteger(gap.bitLength(), _rand);
}
BigInteger startInt = convertIPv6AddressToBigInteger(start);
BigInteger resultInt = startInt.add(next);
InetAddress resultAddr;
try {
resultAddr = InetAddress.getByAddress(resultInt.toByteArray());
} catch (UnknownHostException e) {
return null;
}
IPv6Address ip = IPv6Address.fromInetAddress(resultAddr);
return ip.toString();
}