InetAddress and IP-addresses
1 posts in topic
Flat View  Flat View

Posted By:   Zeta_Kouper
Posted On:   Thursday, May 26, 2005 11:12 AM

Hi!Pleaseanyone who can answer my question!!

Do you know how I can construct an InetAddress object in Java using the IP-address of a host in the format :


There is no way to do that in the java.net.InetAddress API.

I have to use the host name as a String or the ip address

as a byte array, but 147 for example exceeds the limits

of the MAX_VALUE for a byte.

Thank you very much!!

Re: InetAddress and IP-addresses

Posted By:   Anonymous  
Posted On:   Tuesday, June 14, 2005 10:33 PM

I don't think there is a way to get the ip address as an array of bytes(to be used to create a InetAddress object using getByAddress(byte[] b)) other than using the byte[] getAddress() method.

InetAddress inet = InetAddress.getByName("www.sun.com");
InetAddress inet2 = InetAddress.getByAddress(inet.getAddress());
About | Sitemap | Contact