0% found this document useful (0 votes)
60 views1 page

Aim: Algorithm:: Finding The Ip Address

The document provides a Java program to find the IP address of the local system. It declares an InetAddress variable to store the IP, uses getLocalHost() to get the local host address, and getHostName() to get the system name. It then uses getByName() to find the IP address of another system by specifying its name. The program outputs the local IP address, system name, and IP of another system.

Uploaded by

Sudesh Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views1 page

Aim: Algorithm:: Finding The Ip Address

The document provides a Java program to find the IP address of the local system. It declares an InetAddress variable to store the IP, uses getLocalHost() to get the local host address, and getHostName() to get the system name. It then uses getByName() to find the IP address of another system by specifying its name. The program outputs the local IP address, system name, and IP of another system.

Uploaded by

Sudesh Agrawal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

FINDING THE IP ADDRESS

AIM:
To write a java program to find the IP address of the system.

ALGORITHM:
1. Start
2. Declare a variable ip as a static InetAddress.
3. Using the function getLocalHost() to find the address of the system.
4. Get the name of the system by using the getHostName() function.
5. By specifying the system name, find out the IP address of the system using
the function getByName().
6. Stop.

FINDING IP ADDRESS
SOURCE CODE:
import java.io.*;
import java.net.*;
class address
{
public InetAddress ip;
public static void main(String args[])throws UnknownHostException
{
InetAddress ip=InetAddress.getLocalHost();
System.out.println("\n IP address is: "+ip);
String s1=ip.getHostName();
System.out.println("system number is: "+s1);
InetAddress ip1=InetAddress.getByName("system 10");
System.out.println("\n name of other system is: "+ip1);
}}

OUTPUT:

You might also like