且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Java取得本机IP和机器名

更新时间:2022-09-23 21:03:55

使用Java取得本机IP和机器名
        try
        {
            InetAddress addr = InetAddress.getLocalHost();
            String ip=addr.getHostAddress().toString();//获得本机IP
            String host=addr.getHostName().toString();//获得本机名称

} catch(Exception e){ }
使用Java取得本机IP和机器名

 












本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/xiandedanteng/p/4211188.html,如需转载请自行联系原作者