Results 1 to 3 of 3
  1. #1
    dewitrydan is offline Member
    Join Date
    Aug 2010
    Posts
    67
    Rep Power
    0

    Default InetAddress.getByName

    Hi, I am confused as to what this method does.
    In the documentation, it says it return "an IP address for the given host name."
    Thats fine...
    but when I test it:
    Java Code:
    System.out.println(InetAddress.getByName("google.com"));
    it prints:
    Java Code:
    google.com/173.194.37.104
    Why does it add the google.com bit in front of the IP address? :S
    Isnt it just supposed to return only the IP address? or am I missing something?
    Thanks

  2. #2
    dewitrydan is offline Member
    Join Date
    Aug 2010
    Posts
    67
    Rep Power
    0

    Default

    anyone????????????????

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,305
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by dewitrydan View Post
    anyone????????????????
    This is what the API documentation has to say about it:

    Quote Originally Posted by API documentation
    toString
    public String toString()Converts this IP address to a String. The string returned is of the form: hostname / literal IP address. If the host name is unresolved, no reverse name service loopup is performed. The hostname part will be represented by an empty string.

    Overrides:
    toString in class Object
    Returns:
    a string representation of this IP address.
    The behaviour is well documented ...

    kind regards,

    Jos

Similar Threads

  1. InetAddress.getLocalHost() issue...
    By shahdharmit in forum Networking
    Replies: 1
    Last Post: 10-18-2009, 02:22 AM
  2. convert InetAddress to a string
    By hunterbdb in forum New To Java
    Replies: 4
    Last Post: 10-18-2008, 09:50 AM

Posting Permissions

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