Here you can find the source of normalizeHostAddress(final InetAddress localHost)
public static String normalizeHostAddress(final InetAddress localHost)
//package com.java2s; //License from project: Apache License import java.net.Inet6Address; import java.net.InetAddress; public class Main { public static String normalizeHostAddress(final InetAddress localHost) { if (localHost instanceof Inet6Address) { return "[" + localHost.getHostAddress() + "]"; } else {/* www . ja v a2 s . c o m*/ return localHost.getHostAddress(); } } }