List of utility methods to do IP Address Get
String | getIntranetIp() get Intranet Ip if (intranetIp == null) { try { intranetIp = InetAddress.getLocalHost().getHostAddress(); } catch (Exception e) { intranetIp = "127.0.0.1"; return intranetIp; ... |
InetAddress | getIP() Get an IP. if (_ip != null) { return _ip; Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces(); NetworkInterface ni; while (nis.hasMoreElements()) { ni = nis.nextElement(); if (!ni.isLoopback() && ni.isUp()) { ... |
String | getIp() get Ip if (null != cachedIpAddress) { return cachedIpAddress; Enumeration<NetworkInterface> netInterfaces; try { netInterfaces = NetworkInterface.getNetworkInterfaces(); } catch (final SocketException ex) { return "unknown ip"; ... |
byte[] | getIP() get IP try { Enumeration allNetInterfaces = NetworkInterface.getNetworkInterfaces(); InetAddress ip = null; byte[] internalIP = null; while (allNetInterfaces.hasMoreElements()) { NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement(); Enumeration addresses = netInterface.getInetAddresses(); while (addresses.hasMoreElements()) { ... |
String | getIp() Gets my IP as String. try { List<String> ips = new ArrayList<String>(); Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface current = interfaces.nextElement(); if (current.isUp() && !current.isLoopback() && !current.isVirtual()) { Enumeration<InetAddress> addresses = current.getInetAddresses(); while (addresses.hasMoreElements()) { ... |
String | getIp() get Ip String ip = null; try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface iface = interfaces.nextElement(); if (iface.isLoopback() || !iface.isUp()) continue; Enumeration<InetAddress> addresses = iface.getInetAddresses(); ... |
String | getIp() Checks public IP address from Amazon's API URL whatismyip = new URL("http://checkip.amazonaws.com"); BufferedReader in = null; try { in = new BufferedReader(new InputStreamReader(whatismyip.openStream())); String ip = in.readLine(); return ip; } finally { if (in != null) { ... |
String | getIp() get Ip if (ipAddress == null) { try { URL whatismyip = new URL("http://checkip.amazonaws.com"); try (BufferedReader in = new BufferedReader(new InputStreamReader(whatismyip.openStream()))) { ipAddress = in.readLine(); } catch (Throwable e) { System.err.println("Unable to retrieve this machine's external ip: " + e.getMessage()); ... |
String | getIp() get Ip InetAddress ip; try { ip = InetAddress.getLocalHost(); return ip.getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); return "localhost"; ... |
String | getIP() get IP String ip = ""; try { Enumeration<?> e1 = (Enumeration<?>) NetworkInterface.getNetworkInterfaces(); while (e1.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) e1.nextElement(); if (!ni.getName().equals("eth0")) { continue; } else { ... |