List of utility methods to do Integer to IP Address
String | int2ip(int ipInt) intip return new StringBuilder().append(((ipInt >> 24) & 0xff)).append('.').append((ipInt >> 16) & 0xff) .append('.').append((ipInt >> 8) & 0xff).append('.').append((ipInt & 0xff)).toString(); |
String | int2IP(long ip) int IP StringBuffer sb = new StringBuffer(15); for (int shift = 24; shift > 0; shift -= 8) { sb.append(Long.toString((ip >>> shift) & 0xff)); sb.append('.'); sb.append(Long.toString(ip & 0xff)); return sb.toString(); |
String | Int2Ip(long ip) Int Ip long[] b = new long[4]; b[0] = (long) ((ip >> 24) & 0xff); b[1] = (long) ((ip >> 16) & 0xff); b[2] = (long) ((ip >> 8) & 0xff); b[3] = (long) (ip & 0xff); return b[0] + "." + b[1] + "." + b[2] + "." + b[3]; |
String | int2IpAddressString(long i) int Ip Address String long b0 = (i >> 24) & 0xff; long b1 = (i >> 16) & 0xff; long b2 = (i >> 8) & 0xff; long b3 = i & 0xff; StringBuilder sb = new StringBuilder(); sb.append(b0).append("."); sb.append(b1).append("."); sb.append(b2).append("."); ... |
String | int2ipstr(int addr) intipstr int[] intAddr = new int[4]; for (int i = 3; i >= 0; i--) { intAddr[i] = addr & 0xFF; addr >>= 8; return String.format("%d.%d.%d.%d", intAddr[0], intAddr[1], intAddr[2], intAddr[3]); |
String | int2IpStr(long ip) int Ip Str String ipStr = String.format("%d.%d.%d.%d", (ip & 0x00000000ff000000) >> 24, (ip & 0x0000000000ff0000) >> 16, (ip & 0x000000000000ff00) >> 8, ip & 0x00000000000000ff); return ipStr; |
String | intToIp(int address) int To Ip StringBuilder result = new StringBuilder(); result.append((address & 0xFF000000) >>> 24).append("."); result.append((address & 0x00FF0000) >>> 16).append("."); result.append((address & 0x0000FF00) >>> 8).append("."); result.append(address & 0x000000FF); return result.toString(); |
String | intToIp(int i) int To Ip return ((i >> 24) & 0xFF) + "." + ((i >> 16) & 0xFF) + "." + ((i >> 8) & 0xFF) + "." + (i & 0xFF); |
String | intToIp(int i) Converts an integer IP address into its text form. StringBuilder out = new StringBuilder(15); out.append((i >> 24) & 0xFF); out.append("."); out.append((i >> 16) & 0xFF); out.append("."); out.append((i >> 8) & 0xFF); out.append("."); out.append(i & 0xFF); ... |
String | intToIp(int i) int To Ip return String.valueOf(i >> FIRST_ADDRESS_OCTET_SHIFT & XOR_DEFAULT_VALUE) + '.' + (i >> SECOND_ADDRESS_OCTET_SHIFT & XOR_DEFAULT_VALUE) + '.' + (i >> THIRD_ADDRESS_OCTET_SHIFT & XOR_DEFAULT_VALUE) + '.' + (i & XOR_DEFAULT_VALUE); |