Java Utililty Methods Integer to IP Address

List of utility methods to do Integer to IP Address

Description

The list of methods to do Integer to IP Address are organized into topic(s).

Method

StringintToIP(int intIP)
Convert an IP from int to textual presentation.
int[] nums = new int[4];
for (int i = 3; i > -1; --i) {
    nums[i] = intIP & 0xff;
    intIP >>= 8;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 3; ++i) {
    sb.append(nums[i]).append('.');
...
StringintToIp(int ip)
int To Ip
return String.format("%s.%s.%s.%s", (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF);
StringintToIP(int ipAddr)
int To IP
long ip = 0xFFFFFFFFL & ipAddr;
String str = new Long(ip % 256).toString();
str = "." + str;
ip >>>= 8;
str = new Long(ip % 256).toString() + str;
str = "." + str;
ip >>>= 8;
str = new Long(ip % 256).toString() + str;
...
StringintToIp(int ipInt)
int To Ip
return new StringBuilder().append(((ipInt >> 24) & 0xff)).append('.').append((ipInt >> 16) & 0xff)
        .append('.').append((ipInt >> 8) & 0xff).append('.').append((ipInt & 0xff)).toString();
StringintToIpAddr(int ip)
int To Ip Addr
return "" + String.valueOf((ip) >>> 24) + "." + String.valueOf((ip & 0x00FFFFFF) >>> 16) + "."
        + String.valueOf((ip & 0x0000FFFF) >>> 8) + "." + String.valueOf(ip & 0x000000FF);
StringintToIpAddress(int i)
int To Ip Address
StringBuilder buf = new StringBuilder(15);
buf.append(i >> 24 & 0xff);
buf.append('.');
buf.append(i >> 16 & 0xff);
buf.append('.');
buf.append(i >> 8 & 0xff);
buf.append('.');
buf.append(i & 0xff);
...
StringintToIpString(int ip)
int To Ip String
StringBuffer sb = new StringBuffer();
sb.append((ip >> 24) & 0x0FF);
sb.append(".");
sb.append((ip >> 16) & 0x0FF);
sb.append(".");
sb.append((ip >> 8) & 0x0FF);
sb.append(".");
sb.append((ip >> 0) & 0x0FF);
...
StringintToIpV4(int i)
int To Ip V
int b1 = (i >> 24) & 0xff;
int b2 = (i >> 16) & 0xff;
int b3 = (i >> 8) & 0xff;
int b4 = i & 0xff;
return b1 + "." + b2 + "." + b3 + "." + b4;
StringintToIpV4String(int intIp)
int To Ip V String
return ((intIp >> 24) & 0xFF) + "." + ((intIp >> 16) & 0xFF) + "." + ((intIp >> 8) & 0xFF) + "."
        + (intIp & 0xFF);