U0.java

import java.net.*;

/**
Simple demo of <code>InetAddress</code> class.
*/
class U0
{
    public static void main(String argv[])
    {
        String[] name = {
            "leipold", 
            "www.ace-net.com",
            "www.bozoid.com",
            "xxx.yyy.zzz",
            };

        for (int k=0; k<name.length; k++) {
            System.out.print(name[k] + ": ");
            try {
                InetAddress a = InetAddress.getByName(name[k]);
                byte[] b = a.getAddress();
                for (int i=0; i<b.length; i++) {
                    if (i > 0)
                        System.out.print(".");
                    System.out.print((int)((b[i]+256) % 256));
                    }
                }
            catch (UnknownHostException e) {
                //e.printStackTrace();
                System.out.print("NOT FOUND!");
                }
            System.out.println();
            }

        // Look up this host's address.
        try {
            InetAddress here = InetAddress.getLocalHost();
            System.out.println("Local host: " + here);
            }
        catch (UnknownHostException e) {
            e.printStackTrace();
            }
    }
}