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[] args) throws 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]);
}
}
} |
|