@Test(expected = IllegalArgumentException.class) public void testHostPartiallyNoPortIPv6() { String uaddr = "fe80::21c:c0ff:fea0:caf4.1"; InetSocketAddresses.forUaddrString(uaddr); }
public static InetSocketAddress forUaddrString(String uaddr) { int secondPort = uaddr.lastIndexOf('.'); if( secondPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } int firstPort = uaddr.lastIndexOf('.', secondPort -1); if( firstPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } InetAddress inetAddr = forString(uaddr.substring(0, firstPort)); int p1 = Integer.parseInt(uaddr.substring(firstPort +1, secondPort)); int p2 = Integer.parseInt(uaddr.substring(secondPort +1)); int port = (p1 << 8) + p2; return new InetSocketAddress(inetAddr, port); }
InetSocketAddresses { public static InetSocketAddress forUaddrString(String uaddr) { int secondPort = uaddr.lastIndexOf('.'); if( secondPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } int firstPort = uaddr.lastIndexOf('.', secondPort -1); if( firstPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } InetAddress inetAddr = forString(uaddr.substring(0, firstPort)); int p1 = Integer.parseInt(uaddr.substring(firstPort +1, secondPort)); int p2 = Integer.parseInt(uaddr.substring(secondPort +1)); int port = (p1 << 8) + p2; return new InetSocketAddress(inetAddr, port); } }
InetSocketAddresses { public static InetSocketAddress forUaddrString(String uaddr) { int secondPort = uaddr.lastIndexOf('.'); if( secondPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } int firstPort = uaddr.lastIndexOf('.', secondPort -1); if( firstPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } InetAddress inetAddr = forString(uaddr.substring(0, firstPort)); int p1 = Integer.parseInt(uaddr.substring(firstPort +1, secondPort)); int p2 = Integer.parseInt(uaddr.substring(secondPort +1)); int port = (p1 << 8) + p2; return new InetSocketAddress(inetAddr, port); } private  InetSocketAddresses(); }
InetSocketAddresses { public static InetSocketAddress forUaddrString(String uaddr) { int secondPort = uaddr.lastIndexOf('.'); if( secondPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } int firstPort = uaddr.lastIndexOf('.', secondPort -1); if( firstPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } InetAddress inetAddr = forString(uaddr.substring(0, firstPort)); int p1 = Integer.parseInt(uaddr.substring(firstPort +1, secondPort)); int p2 = Integer.parseInt(uaddr.substring(secondPort +1)); int port = (p1 << 8) + p2; return new InetSocketAddress(inetAddr, port); } private  InetSocketAddresses(); static InetSocketAddress forUaddrString(String uaddr); static InetSocketAddress inetAddressOf(String address); static String uaddrOf(InetSocketAddress socketAddress); static String uaddrOf(String host, int port); static String tcpNetidOf(InetAddress address); }
InetSocketAddresses { public static InetSocketAddress forUaddrString(String uaddr) { int secondPort = uaddr.lastIndexOf('.'); if( secondPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } int firstPort = uaddr.lastIndexOf('.', secondPort -1); if( firstPort == -1 ) { throw new IllegalArgumentException("address " + uaddr + " doesn't match rfc5665"); } InetAddress inetAddr = forString(uaddr.substring(0, firstPort)); int p1 = Integer.parseInt(uaddr.substring(firstPort +1, secondPort)); int p2 = Integer.parseInt(uaddr.substring(secondPort +1)); int port = (p1 << 8) + p2; return new InetSocketAddress(inetAddr, port); } private  InetSocketAddresses(); static InetSocketAddress forUaddrString(String uaddr); static InetSocketAddress inetAddressOf(String address); static String uaddrOf(InetSocketAddress socketAddress); static String uaddrOf(String host, int port); static String tcpNetidOf(InetAddress address);  }