Java Socket Address Get getIpAddress(SocketAddress sa)

Here you can find the source of getIpAddress(SocketAddress sa)

Description

get Ip Address

License

Open Source License

Declaration

public static String getIpAddress(SocketAddress sa) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.SocketAddress;

public class Main {

    public static String getIpAddress(SocketAddress sa) {
        String ip = sa.toString();
        if (ip == null)
            return "";
        if (ip.startsWith("/"))
            ip = ip.substring(1);//from  w  ww.  j  a  v a2s .co  m
        int i = ip.indexOf(":");
        if (i > 0)
            ip = ip.substring(0, i);
        return ip;
    }
}

Related

  1. getInetSocketAddress(String s, String mainHost)
  2. getInetSocketAddressFromStringStrict(String s)
  3. getInetSocketTransportAddressConstructor()
  4. getIp(SocketAddress socketAddress)
  5. getIpAddress(Socket socket)
  6. getIpAsString(SocketAddress address)
  7. getLocalAddress(Socket socket)
  8. getLocalSocketAddress(String host, int port)
  9. getNetworkVersion(InetSocketAddress address)