日期:2014-05-20 浏览次数:20871 次
import java.net.InetAddress; import java.net.UnknownHostException; public class GetHost112 { public static void main(String[] args) { try { // System.out.println("InetAddress.getLocalHost().getHostAddress()"); System.out.println(InetAddress.getLocalHost().getHostAddress()); // System.out.println("InetAddress.getB" // + "yName(\"hp-HP\").getHostAddress()"); System.out.println(InetAddress.getByName("hp-HP").getHostAddress()); } catch (UnknownHostException e) { e.printStackTrace(); } } }