I don't think there's any built-in way to extract the domain name. You'd probably just have to look for patterns matching valid domain name formats.
As for getting "the" URL, no, that's not possible. There is no single URL associated with an IP address. A URL is a completely independent thing that has a host component, but there might be zero, one, or many valid URLs for any given host. You can of course construct one using a common format from the host name or IP address, just by building up the appropriate String, and then test to see if you get a response from that URL. You don't even need the InetAddress for that.
Joined: Sep 20, 2012
Here i am getting my computer name and my computer ip as an output. Now suppose i have an another lappy connected with my lappy through modem and i am intending to get its computer name and its IP address ( which i manually assigned it as 192.168.1.3 ) . What changes i am supposed to do ?
I think the method is InetAddress.getByName(). Look at the docs to confirm, or to find the right method or right spelling. You give it a host either by name or by IP address, and it returns the corresponding InetAddress. Note that the resulting name/address pairing won't always be what you expect. The "computer name" that you see when you log on to your computer won't necessarily be the same as what is given by whatever service responds to InetAddress's request.
Note that in this context, you have to know either the name (noting that the name by which the computer knows itself may not work) or the address.
If your question is really "How do I find the names and addresses of all the computers on my network?" then I can't help you with that.
subject: Can we get Domain Name as we pass IP address ?