Here you can find the source of longToIpV4(long ip)
public static final String longToIpV4(long ip)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 BowenCai.//from w w w. j av a 2 s. co m * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * BowenCai - initial API and implementation ******************************************************************************/ public class Main { public static final String longToIpV4(long ip) { StringBuilder sb = new StringBuilder(15); for (int i = 0; i < 4; i++) { sb.insert(0, Long.toString(ip & 0xff)); if (i < 3) { sb.insert(0, '.'); } ip >>= 8; } return sb.toString(); } }