Here you can find the source of getIP(InetAddress ip)
public static String getIP(InetAddress ip)
//package com.java2s; //License from project: Creative Commons License import java.net.InetAddress; public class Main { public static String getIP(InetAddress ip) { return ip.getHostAddress().replace("/", ""); }//from www. jav a 2s .c om public static String getIP(String ip) { ip = ip.replace("/", ""); String[] withoutPort = ip.split(":"); if (withoutPort.length == 2) return withoutPort[0]; else return ip; } }