InetAddress GetByAddress() Example

Returns an InetAddress object given the raw IP address .


InetAddressclass GetByAddress() method example. This example shows you how to use GetByAddress() method.This method Returns an InetAddress object given the raw IP address .

Here is the code:-
/* 
 * @Program that Returns an InetAddress object given the raw IP address .
 * GetByAddress.java 
 * Author:-RoseIndia Team
 * Date:-19-Jun-2008
 */

import java.net.*;

public class GetByAddress {

    public static void main(String[] argsthrows UnknownHostException {
        byte[] b = new byte[4];
        InetAddress ob1 = InetAddress.getByName("girish-desktop");
        b0new Integer(127).byteValue();
        b1new Integer(2).byteValue();
        b2new Integer(8).byteValue();
        b3new Integer(24).byteValue();
        //Returns an InetAddress object given the raw IP address .
        InetAddress ob2 = InetAddress.getByAddress(b);
        System.out.println("InetAddress  of object is : "+ob2);
    }
}

Output of the program:-
InetAddress  of object is : /127.2.8.24

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US