获得指定网面的IP地址

try
  {
       URL url = new URL(“urlAddress”);
       InetAddress address = InetAddress.getByName(url.getHost());
       String ip = address.getHostAddress();
       System.out.println(ip);
       System.out.println(url.getHost());
  }
  catch (MalformedURLException e)
  { //
     e.printStackTrace();
  }
  catch (IOException e)
  {
      e.printStackTrace();
  }

你可能感兴趣的:(IP)