2020
10-09
10-09
java获取linux服务器上的IP操作
在编码过程中需要获取本地IP地址,首先使用的是下面的方法,在Windows环境正常,但是linux服务器上就获取不到,publicstaticStringgetIpAddress(){StringhostAddress="";try{InetAddressaddress=InetAddress.getLocalHost();hostAddress=address.getHostAddress();}catch(UnknownHostExceptione){e.printStackTrace();}returnhostAddress;}这样在linux上依然获取到的是127.0.0.1,查询服务器上面IP...
继续阅读 >