List of utility methods to do IP Address Get
String | getStrLocalIP() get Str Local IP String ip = null; Enumeration<NetworkInterface> enuNI = NetworkInterface.getNetworkInterfaces(); begin: while (enuNI.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) enuNI.nextElement(); Enumeration<InetAddress> enuAddress = ni.getInetAddresses(); while (enuAddress.hasMoreElements()) { InetAddress address = enuAddress.nextElement(); if (!address.isSiteLocalAddress() && !address.isLoopbackAddress() ... |
String | getVisibleIp() get Visible Ip String ip = getProperty("ip"); if (ip == null || ip.trim().length() == 0) { InputStream in = null; try { HttpURLConnection connection = (HttpURLConnection) new URL("https://cp.vu/show_my_ip") .openConnection(); ip = new BufferedReader(new InputStreamReader(in = connection.getInputStream())).readLine(); } catch (IOException e) { ... |
String | getWinLocalIP() get Win Local IP String ip = ""; try { Enumeration<?> e1 = (Enumeration<?>) NetworkInterface.getNetworkInterfaces(); while (e1.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) e1.nextElement(); Enumeration<?> e2 = ni.getInetAddresses(); while (e2.hasMoreElements()) { InetAddress ia = (InetAddress) e2.nextElement(); ... |
InetAddress | getWinLocalIp() get Win Local Ip InetAddress inet = InetAddress.getLocalHost();
return inet;
|