InetAddress GetLocalHost() Example
Returns the local host.
InetAddressclass GetLocalHost() method example. This example shows you how to use GetLocalHost() method.This method Returns the local host.
Here is the code:-
/*
* @Program that Returns the local host.
* GetLocalHost.java
* Author:-RoseIndia Team
* Date:-19-Jun-2008
*/
import java.net.*;
public class GetLocalHost {
public static void main(String args[]) throws UnknownHostException {
InetAddress ia = InetAddress.getLocalHost();
//Returns the local host.
System.out.println("Local IP Address is : " + ia);
}
}
|
Output of the program:-
| Local IP Address is : girish-desktop/127.0.1.1 |
|