Here you can find the source of getIPFromHash(final long ipHash)
public static final byte[] getIPFromHash(final long ipHash)
//package com.java2s; /*//from ww w . ja va2s.co m * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. */ import java.net.InetAddress; public class Main { public static final byte[] getIPFromHash(final long ipHash) { final byte[] ip; if (isIPv6(ipHash)) { ip = new byte[] { (byte) (ipHash & 0xFF), (byte) (ipHash >> 8 & 0xFF), (byte) (ipHash >> 16 & 0xFF), (byte) (ipHash >> 24 & 0xFF), (byte) (ipHash >> 32 & 0xFF), (byte) (ipHash >> 40 & 0xFF) }; } else { ip = new byte[] { (byte) (ipHash & 0xFF), (byte) (ipHash >> 8 & 0xFF), (byte) (ipHash >> 16 & 0xFF), (byte) (ipHash >> 24 & 0xFF) }; } return ip; } public static final boolean isIPv6(final InetAddress address) { return isIPv6(address.getAddress()); } public static final boolean isIPv6(final byte[] address) { return address.length == 6; } public static final boolean isIPv6(final long ipHash) { return ipHash < 0; } }