Results 1 to 2 of 2
  1. #1
    abhijeet_152 is offline Member
    Join Date
    Nov 2008
    Posts
    1
    Rep Power
    0

    Default 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...

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default 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 188477749X
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. Replies: 3
    Last Post: 07-25-2011, 03:19 PM
  2. Get the IP address&hostname of the host from the LANs
    By linux0kernel in forum Networking
    Replies: 3
    Last Post: 10-16-2008, 01:43 PM
  3. How to track client logout time and orignal ipaddress (not gateway) in java
    By psandeep in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-13-2008, 12:32 AM
  4. IP to HostName
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-11-2007, 08:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •