Java Socket Address Get getInetSocketAddress(String endpoint)

Here you can find the source of getInetSocketAddress(String endpoint)

Description

Convert an endpoint from String (host:port) to InetSocketAddress

License

Open Source License

Parameter

Parameter Description
endpoint a String in (host:port) format

Return

an InetSocketAddress representing the endpoint

Declaration

public static InetSocketAddress getInetSocketAddress(String endpoint) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.net.InetSocketAddress;

public class Main {
    /**//  ww w . j av a2  s. com
     * Convert an endpoint from String (host:port) to InetSocketAddress
     *
     * @param endpoint a String in (host:port) format
     * @return an InetSocketAddress representing the endpoint
     */
    public static InetSocketAddress getInetSocketAddress(String endpoint) {
        String[] array = endpoint.split(":");
        return new InetSocketAddress(array[0], Integer.parseInt(array[1]));
    }
}

Related

  1. getHostStringFromInetSocketAddress(InetSocketAddress addr)
  2. getHostStringWithoutNameLookup( InetSocketAddress inetSocketAddress)
  3. getInetSocketAddress(long addrAsInt32, int port)
  4. getInetSocketAddress(String addressPortStr, int defaultPort)
  5. getInetSocketAddress(String arg)
  6. getInetSocketAddress(String endpointURI, int defaultPort)
  7. getInetSocketAddress(String s, String mainHost)
  8. getInetSocketAddressFromStringStrict(String s)
  9. getInetSocketTransportAddressConstructor()