List of utility methods to do IP Address Get
String | getHostIPByHostName(String host) get Host IP By Host Name InetAddress inetAddress; try { inetAddress = InetAddress.getByName(host); return inetAddress.getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); return null; ... |
List | getInetIps() get Inet Ips List<String> ipList = new LinkedList<>(); try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); NetworkInterface networkInterface; Enumeration<InetAddress> inetAddresses; InetAddress inetAddress; String ip; while (networkInterfaces.hasMoreElements()) { ... |
InputStream | getIniFileInputStreamEclipse() Get the bpel4chor.ini file InputStream, the File Path is provided from eclipse bundle. InputStream in = null; Bundle bundle = Platform.getBundle("org.bpel4chor.model"); Path path = new Path("config/bpel4chor.ini"); URL fileURL = FileLocator.find(bundle, path, null); try { if (fileURL != null) { URL absoluteUrl = Platform.resolve(fileURL); in = absoluteUrl.openStream(); ... |
InputStream | getInputStreamFromZipFile(String zipFilePath, String resourcePath) get Input Stream From Zip File URL metadata = new URL(String.format("jar:file:%s!/%s", zipFilePath, resourcePath)); return metadata.openStream(); |
InetAddress | getInterfaceAddress(final String ifaceName, final boolean ipV4) Get the first address found for the given interface. try { NetworkInterface iface = NetworkInterface.getByName(ifaceName); for (InetAddress ifAddr : Collections.list(iface.getInetAddresses())) { if (ifAddr instanceof Inet4Address && ipV4) { return ifAddr; } else if (ifAddr instanceof Inet6Address && !ipV4) { return ifAddr; return null; } catch (SocketException ex) { return null; |
TreeSet | getInterfaceIPs() Gets every IPv4 Address on each Interface except the loopback The Address format is ip/subnet TreeSet<String> interfaceIPs = new TreeSet<String>(); try { for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en .hasMoreElements();) { NetworkInterface networkInterface = en.nextElement(); if (!networkInterface.isLoopback()) { for (Iterator<InterfaceAddress> it = networkInterface.getInterfaceAddresses().iterator(); it .hasNext();) { ... |
String | getInternalIp() get Internal Ip Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); while (ifaces.hasMoreElements()) { NetworkInterface iface = ifaces.nextElement(); Enumeration<InetAddress> addresses = iface.getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress addr = addresses.nextElement(); if (addr instanceof Inet4Address && !addr.isLoopbackAddress()) { return addr.getHostAddress(); ... |
String | getInternalIp() Get the internal IP of the machine where is launched Messic InetAddress thisIp = getLocalHostLANAddress();
return thisIp.getHostAddress().toString();
|
String | getInternetIpAddress() get Internet Ip Address URL oUrl = new URL("http://checkip.amazonaws.com"); BufferedReader brINPUT = null; try { brINPUT = new BufferedReader(new InputStreamReader(oUrl.openStream())); String strReturnIP = brINPUT.readLine(); return strReturnIP; } finally { if (brINPUT != null) { ... |
int | getIntfFromLabelAdva(int n, Inet4Address ip) get Intf From Label Adva if ((n == 5) && (ip.getHostAddress().equals("172.16.1.40"))) { return 27; } else if ((n == 8) && (ip.getHostAddress().equals("172.16.1.40"))) { return 25; } else if ((n == 8) && (ip.getHostAddress().equals("172.16.1.38"))) { return 21; } else if ((n == 7) && (ip.getHostAddress().equals("172.16.1.38"))) { return 17; ... |