A simple example in Java you need to get the IP address of a domain
import java.net.InetAddress;
import java.net.UnknownHostException;
public class IPAddressTools {
public static void main(String[] args)
{
InetAddress inetAddress;
try
{
String domain = "";
if(args.length > 0 && args[0]!="")
domain = args[0];
else
domain = "mdmsoft.it";
inetAddress = InetAddress.getByName(domain);
System.out.println("Domain: " + domain);
System.out.println("IP Address: " + inetAddress.getHostAddress());
}
catch(UnknownHostException e)
{
System.out.println("Houston we have a problem!:");
System.out.println(e.toString());
}
}
}
Use with parameter passed as an argument:
>java -cp . IPAddressTools msn.com
Domain: msn.com
IP Address: 65.55.206.228
>Exit code: 0
Using no parameters:
>java -cp . IPAddressTools
Domain: mdmsoft.it
IP Address: 62.149.128.160
>Exit code: 0