获取IP地址的主机名
import java.net.InetAddress; import java.net.UnknownHostException; public class Main {/**from 时代Java公众号 - N o w J a v a . c o m**/ public void m() { 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