Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

Java IP Address

Let's know how to get the IP Address of a website on Internet by using getByName() method which takes host name as argument and returns InetAddress which is nothing but a IPAddress of that server. Let's see the following program: import*;

class Address
	public static void main(String args[]) throws IOException
		BufferedReaderbr=new BufferedReader(new InputStreamReader(;
		System.out.println("enter a website name");
		String s=br.readLine();
			InetAddress i=InetAddress.getByName(s);
			System.out.println("the ip address is"+i);
		catch(UnknownHostException u)
			System.out.println("website not found");

enter a website name
theip address

About the Author

Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc