Android examples for java.net:IP Address
Convert long to ip address
public class Main{ public static String long2ip(long ip) { StringBuffer sb = new StringBuffer(); sb.append(String.valueOf((int) (ip & 0xff))); sb.append('.'); sb.append(String.valueOf((int) ((ip >> 8) & 0xff))); sb.append('.'); sb.append(String.valueOf((int) ((ip >> 16) & 0xff))); sb.append('.'); sb.append(String.valueOf((int) ((ip >> 24) & 0xff))); return sb.toString(); }// w w w .j a v a2 s .c o m }