Java Get local IP address
private InetAddress getLocalIPv4Address() {
Enumeration<?> interfaces = null;
try {
interfaces = NetworkInterface.getNetworkInterfaces();
} catch (SocketException e) {
e.printStackTrace();
}
InetAddress ip = null;
if (interfaces != null) {
while (interfaces.hasMoreElements()) {
NetworkInterface ni = (NetworkInterface) interfaces.nextElement();
logger.info("NI: " + ni.getName() + ", " + ni.getDisplayName());
Enumeration<?> addresses = ni.getInetAddresses();
while (addresses.hasMoreElements()) {
ip = (InetAddress) addresses.nextElement();
if (ip != null && (ip instanceof Inet4Address)) {
logger.info("IP addr: " + ip.getHostAddress());
break;
}
}
}
}
return ip;
}
相關文章
- [LeetCode] Validate IP AddressLeetCode
- cluster-wide IP address managementIDE
- git SSL certificate problem: unable to get local issuer certificateGit
- SSL - SSLHandshakeException: No subject alternative names matching IP address foundException
- Oracle 12.2 RAC修改public ip address或public ip(subnet (netmask) or interface)Oracle
- 關於“INS-40922 Invalid Scan Name – Unresolvable to IP address”
- eclipse Java Spark local模式EclipseJavaSpark模式
- [GuzzleHttp\Exception\RequestException] cURL error 60: SSL certificate problem: unable to get localHTTPExceptionError
- GIT clone報錯: SSL certificate problem: unable to get local issuer certificateGit
- Linux虛擬機器配置IP時提示:determining ip information for ip xxx.xxx.xxx.xxx address is alreadyLinux虛擬機ORM
- Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hos
- windows 環境下使用 Node.js 遇到 unable to get local issuer certificateWindowsNode.js
- Can't Connect to MySQL Server on IP Address (10061) 錯誤的解決方案MySqlServer
- Java新提案:Extent-Local變數Java變數
- 解決C3P0在Linux下Failed to get local InetAddress for VMID問題LinuxAI
- xxl-job 報:java.net.BindException: Address already in use: bindJavaIndexException
- Node.js 應用訪問 https 伺服器時遇到 unable to get local issuer certificateNode.jsHTTP伺服器
- 關於使用 git 命令列時遇到的錯誤訊息 unable to get local issuer certificateGit命令列
- java springboot http get請求 URLConnection get 返回值 亂碼JavaSpring BootHTTP
- java11新特性--Local-Variable Syntax for Lambda ParametersJava
- Local Storage
- Redo Byte Address (RBA)(轉)
- Ubuntu 18及以上版本配置 IP 的方法,你 get 了嗎?Ubuntu
- mysql bind_address如何配置多個地址 mysql bind-address選項MySql
- Java Http Get Post 請求工具類JavaHTTP
- java傳送GET和post請求Java
- ORA-00130: invalid listener address
- Java中的TCP/IP協議和IP地址JavaTCP協議
- thread local in pythonthreadPython
- java傳送get請求帶引數Java
- 解決ProtocolHandler ["ajp-nio-8009"] java.net.BindException: Address already in use: bind問題ProtocolJavaIndexException
- java反射呼叫set和get方法的通用類Java反射
- 2.2.2.2 Local Users in a CDB
- Local dimming algorithm in matlabGoMatlab
- Window中安裝gitblit時,IP地址或埠衝突,提示Cannot assign requested address: bind的詳細解決方法Git
- Redis 啟動報錯Address already in useRedis
- Java獲取使用者IPJava
- brew update /usr/local is not writable
- 《龍族幻想》日本發行制勝法寶:比Local更懂Local