Inet4Address GetAddress() Example

returns the raw IP address of object.


Inet4Addressclass GetAddress() method example. This example shows you how to use GetAddress() method.This method returns the raw IP address of object.

Here is the code:-
/* 
 * @Program that returns the raw IP address of object.
 * GetAddress.java 
 * Author:-RoseIndia Team
 * Date:-28-Jun-2008
 */

import java.net.*;
import java.util.*;

public class GetAddress {

    public static void main(String[] argsthrows Exception {
        InetAddress i = Inet4Address.getByName("localhost");
        //returns the raw IP address of object.
        byte b[] = i.getAddress();
         System.out.println("IP address is: ");
        for (int j = 0; j < b.length; j++) {
            System.out.println(b[j]);
        }
    }
}

Output of the program:-
 127
0
0
1

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

HOME | COPYRIGHT | CONTACT US