[英]Find out IP address?
我在android上有一个应用,并且我正在连接到网站以获取一些数据。 是否可以找出我实际连接的IP地址? 我正在做:
HttpUriRequest request = new HttpGet("http://www.example.com");
DefaultHttpClient client = new DefaultHttpClient(params);
HttpResponse response = client.execute(request);
println("You connected to: " + response.getIpAddress(?));
谢谢
您可以使用InetAddress类获取它:
InetAddress addr = InetAddress.getByName(new URL("http://www.example.com").getHost());
String ipAddress = addr.getHostAddress();
只需使用:InetAddress地址= InetAddress.getByName(“ http://www.example.com”);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.