Here you can find the source of getHostAddress(InetAddress host)
public static String getHostAddress(InetAddress host)
//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; } }