InetAddress GetByAddress1() Example

Create an InetAddress based on the provided host name and IP address


InetAddressclass GetByAddress1() method example. This example shows you how to use GetByAddress1() method.This method Create an InetAddress based on the provided host name and IP address

Here is the code:-
/* 
 * @Program that Create an InetAddress based on the provided host name and IP address
 * GetByAddress1.java 
 * Author:-RoseIndia Team
 * Date:-19-Jun-2008
 */

import java.net.*;

public class GetByAddress1 {

    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("Roseindia",b);
        System.out.println("InetAddress based on the provided host name and IP address is : "
                +ob2);
    }
}

Output of the program:-
 InetAddress based on the provided host name and IP address is : Roseindia/127.2.8.24

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

HOME | COPYRIGHT | CONTACT US