InetAddress: getHostAddress() : InetAddress « java.net « Java by API






InetAddress: getHostAddress()

  
 
import java.net.InetAddress;

public class MainClass {

  public static void main(String[] args) {

    try {
      InetAddress me = InetAddress.getLocalHost();
      String dottedQuad = me.getHostAddress();
      System.out.println("My address is " + dottedQuad);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}

   
    
  








Related examples in the same category

1.InetAddress: getAllByName(String name)
2.InetAddress: getByName(String host)
3.InetAddress: getCanonicalHostName()
4.InetAddress: getHostName()
5.InetAddress: getLocalHost()
6.InetAddress: isReachable(int timeout)