Q.Write a program to find out ip address of remote computer.
Source Code:->
import java.net.*;
class Inet1
{
public static void main(String args[]) throws
UnknownHostException
{
InetAddress Address = InetAddress.getLocalHost();
System.out.println(Address);
Address = InetAddress.getByName("starwave.com");
System.out.println(Address);
InetAddress SW[] = InetAddress.getAllByName("www.nba.com");
for (int i=0; i<SW.length; i++)
System.out.println(SW[i]);
byte[] addr=new byte[4];
addr[0]=(byte)209;
addr[1]=(byte)191;
addr[2]=(byte)93;
addr[3]=(byte)53;
InetAddress ip=InetAddress.getByAddress(addr);
System.out.println(ip);
}
}
Output:->
D:\student>javac Inet1.java
D:\student>java Inet1
PL10/172.16.23.10
starwave.com/199.181.132.250
www.nba.com/203.106.85.137
www.nba.com/203.106.85.136
No comments:
Post a Comment