List of utility methods to do Socket Address Get
String | toFileName(InetSocketAddress address) Converts the specified address into a string that is suitable for naming files. return FILE_PREFIX + address.getAddress().getHostAddress() + PORT_SEPARATOR + address.getPort();
|
URL | toHttpUrl(InetSocketAddress addr) to Http Url try { return new URL(String.format("http://%s:%d/", addr.getHostString(), addr.getPort())); } catch (MalformedURLException e) { throw new RuntimeException(e); |
InetSocketAddress | toInetSocketAddress(String address) to Inet Socket Address try { URI uri = new URI("pinpoint://" + address); return new InetSocketAddress(uri.getHost(), uri.getPort()); } catch (URISyntaxException ignore) { return null; |
InetSocketAddress | toInetSocketAddress(String hostPortPair, int defaultPort) to Inet Socket Address String[] split = hostPortPair.split(":"); String hostname = split[0]; int port; if (split.length > 1) { port = Integer.parseInt(split[1]); } else { port = defaultPort; InetSocketAddress inetSocketAddress = new InetSocketAddress(hostname, port); return inetSocketAddress; |
List | toInetSocketAddressLIst(List to Inet Socket Address L Ist List<InetSocketAddress> inetSocketAddressList = new ArrayList<InetSocketAddress>(); for (String address : addressList) { InetSocketAddress inetSocketAddress = toInetSocketAddress(address); if (inetSocketAddress != null) { inetSocketAddressList.add(inetSocketAddress); return inetSocketAddressList; ... |
List | toInetSocketAddressList(String addresses, int defaultPort) Parses a comma separated list of ip/host:port pairs. String[] split = addresses.split(","); return toInetSocketAddressList(split, defaultPort); |
InetSocketAddress | toSocketAddress(URL url) Creates a socket address from an URL return new InetSocketAddress(url.getHost(), url.getPort()); |
String | toString(InetSocketAddress addr) to String if (addr == null) { return null; if (addr.isUnresolved()) { return addr.getHostString() + ':' + addr.getPort(); } else { InetAddress ia = addr.getAddress(); return ia.getHostAddress() + ':' + addr.getPort(); ... |
String | toString(InetSocketAddress entryServer) to String return entryServer.getAddress().getHostAddress() + ":" + entryServer.getPort(); |
String | toString(InetSocketAddress socketAddress) Returns <host>:<port> return String.format(TO_STRING_FORMAT, socketAddress.getAddress().getHostAddress(),
socketAddress.getPort());
|