Here you can find the source of getHostAddress(InetAddress address)
Parameter | Description |
---|---|
address | the address |
private static String getHostAddress(InetAddress address)
//package com.java2s; /*//from w ww . jav a 2 s.c o m * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (http://h2database.com/html/license.html). * Initial Developer: H2 Group */ import java.net.Inet6Address; import java.net.InetAddress; public class Main { /** * Get the host address. This method adds '[' and ']' if required for * Inet6Address that contain a ':'. * * @param address the address * @return the host address */ private static String getHostAddress(InetAddress address) { String host = address.getHostAddress(); if (address instanceof Inet6Address) { if (host.indexOf(':') >= 0 && !host.startsWith("[")) { host = "[" + host + "]"; } } return host; } }