这里面包含了一百多个JAVA源文件

源代码在线查看: e145. getting the hostname of an ip address.txt

软件大小: 551 K
上传用户: maple_78
关键词: JAVA
下载地址: 免注册下载 普通下载 VIP

相关代码

				This example attempts to retrieve the hostname for an IP address. Note that getHostName() may not succeed, in which case it simply returns the IP address. 
				    try {
				        // Get hostname by textual representation of IP address
				        InetAddress addr = InetAddress.getByName("127.0.0.1");
				    
				        // Get hostname by a byte array containing the IP address
				        byte[] ipAddr = new byte[]{127, 0, 0, 1};
				        addr = InetAddress.getByAddress(ipAddr);
				    
				        // Get the host name
				        String hostname = addr.getHostName();
				    
				        // Get canonical host name
				        String hostnameCanonical = addr.getCanonicalHostName();
				    } catch (UnknownHostException e) {
				    }
				
							

相关资源