android 通过网址或者域名得到IP地址

android

通过网址或者域名得到IP地址

 

 public static String GetInetAddress(String  host){
  String IPAddress = "";
  InetAddress ReturnStr1 = null;
  try {
   ReturnStr1 = java.net.InetAddress.getByName(host);
   IPAddress = ReturnStr1.getHostAddress();
  } catch (UnknownHostException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   return  IPAddress;
  }
  return IPAddress;
 }

转载于:https://www.cnblogs.com/ddcddc/archive/2012/11/22/2782583.html

你可能感兴趣的:(android 通过网址或者域名得到IP地址)