List of utility methods to do Long to IP Address
String | long2Ip(final long ip) long Ip final StringBuilder result = new StringBuilder(15); result.append(ip >> 24 & 0xff).append("."); result.append(ip >> 16 & 0xff).append("."); result.append(ip >> 8 & 0xff).append("."); result.append(ip & 0xff); return result.toString(); |
String | long2ip(long address) longip long d = address & 0xFF; long c = (address >> 8) & 0xFF; long b = (address >> 16) & 0xFF; long a = (address >> 24) & 0xFF; return String.format("%d.%d.%d.%d", a, b, c, d); |
String | long2ip(long ip) longip byte[] bytes = new byte[4]; bytes[0] = (byte) ((ip & 0xff000000) >> 24); bytes[1] = (byte) ((ip & 0x00ff0000) >> 16); bytes[2] = (byte) ((ip & 0x0000ff00) >> 8); bytes[3] = (byte) (ip & 0x000000ff); String result = new String(String.valueOf((int) bytes[0]) + "." + String.valueOf((int) bytes[1]) + "." + String.valueOf((int) bytes[2]) + "." + String.valueOf((int) bytes[3])); return result; ... |
String | long2ip(long ip) longip return (ip >>> 24 & 0xFF) + "." + (ip >>> 16 & 0xFF) + "." + (ip >>> 8 & 0xFF) + "." + (ip & 0xFF); |
String | long2ip(long ip) longip String result = ""; while (ip > 0) { if (!"".equals(result)) { result = "." + result; result = ip % 256 + result; ip = (long) Math.floor(ip / 256); return result; |
String | long2ip(long ip) int to ip string StringBuilder sb = new StringBuilder(); sb.append((ip >> 24) & 0xFF).append('.').append((ip >> 16) & 0xFF).append('.').append((ip >> 8) & 0xFF) .append('.').append((ip >> 0) & 0xFF); return sb.toString(); |
String | long2ip(long ipLong) longip long mask[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }; long num = 0; StringBuffer ipInfo = new StringBuffer(); for (int i = 0; i < 4; i++) { num = (ipLong & mask[i]) >> (i * 8); if (i > 0) ipInfo.insert(0, "."); ipInfo.insert(0, Long.toString(num, 10)); ... |
String | long2IP(long ipLong) long IP StringBuffer ip = new StringBuffer(String.valueOf(ipLong >> 24) + "."); ip.append(String.valueOf((ipLong & 16711680) >> 16) + "."); ip.append(String.valueOf((ipLong & 65280) >> 8) + "."); ip.append(String.valueOf(ipLong & 255)); return ip.toString(); |
String | long2IP(long proper_address) long IP StringBuilder builder = new StringBuilder(); if (proper_address >= 0) { builder.append((int) (Math.floor(proper_address / Math.pow(256, 3)))); builder.append("."); builder.append((int) (Math.floor((proper_address % Math.pow(256, 3)) / Math.pow(256, 2)))); builder.append("."); builder.append((int) (Math .floor(((proper_address % Math.pow(256, 3)) % Math.pow(256, 2)) / Math.pow(256, 1)))); ... |
String | long2IpAdress(long src) long Ip Adress long l = 256 * 256 * 256; StringBuffer stringBuffer = new StringBuffer(); while (l > 0) { stringBuffer.append(src / l).append("."); src = src % l; l /= 256; stringBuffer.deleteCharAt(stringBuffer.length() - 1); ... |