Here you can find the source of convertInetAddressToLong(InetAddress address)
public static long convertInetAddressToLong(InetAddress address)
//package com.java2s; /*//from w w w.j av a 2 s.c om * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ import java.net.InetAddress; public class Main { public static long convertInetAddressToLong(InetAddress address) { byte[] ipAddressRaw = address.getAddress(); return (((ipAddressRaw[0] & 0xFF) << (3 * 8)) + ((ipAddressRaw[1] & 0xFF) << (2 * 8)) + ((ipAddressRaw[2] & 0xFF) << (1 * 8)) + (ipAddressRaw[3] & 0xFF)) & 0xffffffffL; } }