1 of 5

Advanced JAVA Programming

(COURSE CODE: B19CS2201)

InetAddress class

Sri. M.Jeevana Sujitha

Assistant Professor

Department of Computer Science and Engineering SRKR Engineering College, Bhimavaram, A.P. - 534204

2 of 5

OBJECTIVES

The Objectives of this lecture is

  • To learn about InetAddress class

3 of 5

InetAddress class

  • Java InetAddress class represents an IP address.
  • The java.net.InetAddress class provides methods to get the IP of any host name for example www.google.com, www.facebook.com, etc.
  • An instance of InetAddress represents the IP address with its corresponding host name.

4 of 5

InetAddress class

Method

Description

public static InetAddress getByName(String host) throws UnknownHostException

It returns the instance of InetAddress containing LocalHost IP and name.

public static InetAddress getLocalHost() throws UnknownHostException

It returns the instance of InetAdddress containing local host name and address.

public String getHostName()

It returns the host name of the IP address.

public String getHostAddress()

It returns the IP address in string format.

5 of 5

THANK YOU