Java InetAddress.toString()
Syntax
InetAddress.toString() has the following syntax.
public String toString()
Example
In the following code shows how to use InetAddress.toString() method.
//ww w . ja v a2 s. c om
import java.net.InetAddress;
import java.net.UnknownHostException;
public class Main {
public static void main(String args[]) {
try {
InetAddress inetAddr = InetAddress.getByName("www.java2s.com");
System.out.println(inetAddr.toString());
} catch (UnknownHostException ex) {
}
}
}
The code above generates the following result.