Here you can find the source of ipToString(long ip)
public static String ipToString(long ip)
//package com.java2s; //License from project: Open Source License public class Main { private static char[][] nums256; private static char[] dot; public static String ipToString(long ip) { return ipToString(new StringBuilder(), ip).toString(); }//from w ww.j a va 2 s . c o m public static StringBuilder ipToString(StringBuilder sb, long ip) { sb.append(nums256[(int) (ip >> 24) & 0xFF]); sb.append(dot); sb.append(nums256[(int) (ip >> 16) & 0xFF]); sb.append(dot); sb.append(nums256[(int) (ip >> 8) & 0xFF]); sb.append(dot); sb.append(nums256[(int) (ip) & 0xFF]); return sb; } public static StringBuilder ipToString(StringBuilder sb, int[] ip) { sb.append(nums256[ip[0] & 0xFF]); sb.append(dot); sb.append(nums256[ip[1] & 0xFF]); sb.append(dot); sb.append(nums256[ip[2] & 0xFF]); sb.append(dot); sb.append(nums256[ip[3] & 0xFF]); return sb; } }