public class NetTool
{
  InetAddress myIPAddress = null;
  InetAddress myServer = null;
  
  public static void main(String[] args)
{
System.out.println(new NetTool().getMyIP());
System.out.println(new NetTool().getServerIP("www.csdn.net"));
}

public InetAddress getMyIP()
{
try
{
myIPAddress = InetAddress.getLocalHost();
}
catch (UnknownHostException e)
{
LogManager.debugLog.debug("Caught an exception : ", e);
}

return this.myIPAddress;
}

public InetAddress getServerIP(String webUrl)
{
try
{
myServer = InetAddress.getByName(webUrl);
}
catch (Exception e)
{
LogManager.debugLog.debug("Caught an exception : ", e);
}

return myServer;
}
}