我想根据程序中给定的IP地址找到主机名.
是否有可能得到它,如果是的话,请提供代码.谢谢.
是否有可能得到它,如果是的话,请提供代码.谢谢.
解决方法
是的,它可能.
- import java.net.*;
- public class HostName
- {
- public static void main(String args[])
- {
- InetAddress inetAddress =InetAddress.getByName("127.64.84.2");//get the host Inet using ip
- System.out.println ("Host Name: "+ inetAddress.getHostName());//display the host
- }
- }