FileDocCategorySizeDatePackage
MyAddress6.javaAPI DocExample596Thu Apr 03 15:14:58 BST 1997None

MyAddress6

public class MyAddress6 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


    try {
      InetAddress thisComputer = InetAddress.getLocalHost();
      byte[] address = thisComputer.getAddress();
      System.out.print("My address is ");
      for (int i = 0; i < address.length; i++) {
        int unsignedByte = address[i] < 0 ? address[i] + 256 : address[i];
        System.out.print(unsignedByte + ".");
      }
      System.out.println();
    }
    catch (UnknownHostException e) {
      System.out.println("I'm sorry. I don't know my own address.");
    }