This Java tip illustrates a method of identifying the IP address of a hostname. Developer may use this code in client server or multi user applications where it is require to know the IP Address of the client from where the request came.

 try {
    
        InetAddress addr = InetAddress.getByName("java-tips.org");
        byte[] ipAddr = addr.getAddress();
    
        // Convert to dot representation
        String ipAddrStr = "";
        for (int i=0; i<ipAddr.length; i++) {
            if (i > 0) {
                ipAddrStr += ".";
            }
            ipAddrStr += ipAddr[i]&0xFF;
        }
        
    } catch (UnknownHostException e) {
    }