Java examples for Network:IP Address
get IP from SocketAddress
//package com.java2s; import java.net.SocketAddress; public class Main { public static String getIP(SocketAddress socketAddress) { if (socketAddress == null) { throw new NullPointerException("remoteAddres is null"); }/* w w w . j a v a 2 s . c o m*/ String address = socketAddress.toString(); return address.substring(1, address.indexOf(':')); } }