- try {
- final byte[] bytes = Inet6Address.getByName(p.substring(0, sep)).getAddress();
- return Bytes.concat(bytes, new byte[] { Byte.valueOf(p.substring(sep + 1, p.length())) });
- } catch (final UnknownHostException e) {
- throw new IllegalArgumentException(e.getMessage());
- }
+ final InetAddress a = InetAddresses.forString(p.substring(0, sep));
+ Preconditions.checkArgument(a instanceof Inet6Address);
+ final byte[] bytes = a.getAddress();
+ return Bytes.concat(bytes, new byte[] { Byte.valueOf(p.substring(sep + 1, p.length())) });