public static InetSocketAddress parseBindAddress(String bindAddress) {
        Exception cause = null;
        try {
            if (!bindAddress.contains(":")) {
                // port only
                return new InetSocketAddress(Integer.parseInt(bindAddress));
            }
            // Test for network interface syntax
            Pattern pattern = Pattern.compile(URIUtils.NETWORK_INTERFACE_AUTHORITY_PORT);
            Matcher matcher = pattern.matcher(bindAddress);
            if (matcher.find()) {
                return new InetSocketAddress(matcher.group(1), parseInt(matcher.group(2)));
            }

            // host:port (let URI handle it including ipv6)
            String tmpAddress = "scheme://" + bindAddress;
            URI uri = URI.create(tmpAddress);
            if (uri.getPort() != -1) {
                return new InetSocketAddress(uri.getHost(), uri.getPort());
            }
        } catch (Exception e) {
            // Exception handled outside catch
            cause = e;
        }
        throw new IllegalArgumentException(String.format("Bind address \"%s\" should be in "
                + "\"host/ipv4:port\", \"[ipv6]:port\", \"@network_interface:port\", \"[@network interface]:port\" or \"port\" "
                + "format.", bindAddress), cause);
    }
public static InetSocketAddress parseBindAddress ( String bindAddress ) { Exception cause = null ; try { if ( ! bindAddress . contains ( ":" ) ) { return new InetSocketAddress ( Integer . parseInt ( bindAddress ) ) ; } Pattern pattern = Pattern . compile ( URIUtils . NETWORK_INTERFACE_AUTHORITY_PORT ) ; Matcher matcher = pattern . matcher ( bindAddress ) ; if ( matcher . find ( ) ) { return new InetSocketAddress ( matcher . group ( 1 ) , parseInt ( matcher . group ( 2 ) ) ) ; } String tmpAddress = "scheme://" + bindAddress ; URI uri = URI . create ( tmpAddress ) ; if ( uri . getPort ( ) != - 1 ) { return new InetSocketAddress ( uri . getHost ( ) , uri . getPort ( ) ) ; } } catch ( Exception e ) { cause = e ; } throw new IllegalArgumentException ( String . format ( "Bind address \"%s\" should be in " + "\"host/ipv4:port\", \"[ipv6]:port\", \"@network_interface:port\", \"[@network interface]:port\" or \"port\" " + "format." , bindAddress ) , cause ) ; }
Method creating an InetAddress from String.
@param bindAddress syntax host:port
host optional, can be specified as IPv4, IPv6, NetworkInterface
port mandatory
@return