From 87478ce11910645477d66d985c258900c04ba593 Mon Sep 17 00:00:00 2001 From: malviya <66118964+malviya99@users.noreply.github.com> Date: Thu, 28 Oct 2021 10:46:23 +0530 Subject: [PATCH] get your host's ip address --- Get_Your_IP.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Get_Your_IP.java diff --git a/Get_Your_IP.java b/Get_Your_IP.java new file mode 100644 index 0000000..6d76bcc --- /dev/null +++ b/Get_Your_IP.java @@ -0,0 +1,19 @@ +// InetAddress is used to get ip of any host name; + +import java.net.*; +import java.io.*; + +public class InetAdd{ + public static void main(String[] args) { + + try{ + InetAddress ip = InetAddress.getByName("www.sololearn.com"); + + System.out.println("host Name: "+ip.getHostName()); + + System.out.println("IP Address: "+ip.getHostAddress()); + + } + + catch(Exception e){System.out.println(e);} + }