when I write following code in cmd:
ping localhost
I see following result:
Pinging hostname.A.B.com [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
When I write
InetAddress.getLocalHost().getCanonicalHostName();
it returns only hostname
How can I achieve to return hostname.A.B.com
from java code ?
P.S.
It is not duplicate. I use code from top answer but I don't achieve desired result.