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






InetAddress: getLocalHost()

  
 
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: getHostAddress()
5.InetAddress: getHostName()
6.InetAddress: isReachable(int timeout)