Java InetAddress Create getHostAddress(InetAddress host)

Here you can find the source of getHostAddress(InetAddress host)

Description

get Host Address

License

BSD License

Declaration

public static String getHostAddress(InetAddress host) 

Method Source Code

//package com.java2s;
/*//from   w ww  . j a va 2 s  .  c o  m
 * Copyright (c) 2008-2011 by Jan Stender,
 *               Zuse Institute Berlin
 *
 * Licensed under the BSD License, see LICENSE file for details.
 *
 */

import java.net.Inet6Address;
import java.net.InetAddress;

public class Main {
    public static String getHostAddress(InetAddress host) {

        String hostAddr = host.getHostAddress();
        if (host instanceof Inet6Address) {
            if (hostAddr.lastIndexOf('%') >= 0) {
                hostAddr = hostAddr.substring(0, hostAddr.lastIndexOf('%'));
            }
        }

        return hostAddr;

    }
}

Related

  1. getFreeTCPPort(InetAddress ipAddress)
  2. getFullHostName(InetAddress netAddress)
  3. getHashFromAddress(final InetAddress address)
  4. getHostAddress(InetAddress address)
  5. getHostAddress(InetAddress anAddress)
  6. getHostName(InetAddress address)
  7. getHostName(InetAddress ia)
  8. getHostNameReliably(final String requestingHost, final InetAddress site, final URL requestingUrl)
  9. getHostNameWithoutDomain(final InetAddress addr)