Results 1 to 2 of 2
Thread: IPAddress or HostName
- 11-27-2008, 05:42 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 1
- Rep Power
- 0
IPAddress or HostName
Can I use a Java API to verify whether a String is IPAddress or HostName.
InetAddress.getByName(str) will return an Inet Address for both IPAddress and hostname.
InetAddress.getByAddress(byte[]) requires the IPAddress in a Byte format. How to convert an IP String to this Byte Array ? A simple String.toByteArray() does not yield the correct result.
Inet6Address has a function called textToNumericFormat(String) that returns a Byte Array but this method is hidden and API users cant use them.
Please help !! Thanks in advance...
- 11-27-2008, 06:58 PM #2
Example...
Does the last example in the link help?
InetAddress examples
Luck,
CJSL
- Credits according to the header:
Java Network Programming, Second Edition
Merlin Hughes, Michael Shoffner, Derek Hamner
Manning Publications Company; ISBN 188477749XChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Similar Threads
-
org.apache.commons.mail.EmailException: Cannot find valid hostname
By Ed in forum Advanced JavaReplies: 3Last Post: 07-25-2011, 03:19 PM -
Get the IP address&hostname of the host from the LANs
By linux0kernel in forum NetworkingReplies: 3Last Post: 10-16-2008, 01:43 PM -
How to track client logout time and orignal ipaddress (not gateway) in java
By psandeep in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 06-13-2008, 12:32 AM -
IP to HostName
By Java Tip in forum Java TipReplies: 0Last Post: 11-11-2007, 08:07 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks