I have the following code:
Set<String> ips = allowedIpsToDescriptions.keySet();
where allowedIpsToDescriptions
is a Map<String, String>
I'm trying to convert Set<String>
to Set<InetAddress>
and here's my code:
Set<InetAddress> allowedIpsInetAddr = new HashSet<>();
for (String ip : ips) {
InetAddress inetAddress = InetAddress.getByName(ip);
allowedIpsInetAddr.add(inetAddress);
}
Is there a cleaner / more efficient way of doing this using streams perhaps?