InetAddress.getLocalHost().getHostAddress()
需要:
import java.net.InetAddress;
import java.net.UnknownHostException;
Example:
import java.net.InetAddress;
import java.net.UnknownHostException;
public class GetIPAddressInnerExample {
/**
* @param args
* @throws UnknownHostException
*/
public static void main(String[] args) throws UnknownHostException {
// TODO Auto-generated method stub
System.out.println(InetAddress.getLocalHost().getHostAddress());
}
}
Result:
@CacheTechShare