How to determine Local Host Address using Java? - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Random Posts

How to determine Local Host Address using Java?

Share This



Demo.java
import java.net.*; public class Demo { public static void main(String args[]) { System.out.println ("Looking up local host"); try { InetAddress localAddress = InetAddress.getLocalHost(); System.out.println ("IP address : " + localAddress.getHostAddress()); } catch (UnknownHostException e) { System.out.println("Error - unable to resolve localhost"); } } }

Happy Exploring!

No comments:

Post a Comment