Here you can find the source of convertIPS2Long(String ip)
public static final long convertIPS2Long(String ip)
//package com.java2s; //License from project: Apache License public class Main { public static final long convertIPS2Long(String ip) { char[] c = ip.toCharArray(); byte[] b = { 0, 0, 0, 0 }; for (int i = 0, j = 0; i < c.length;) { int d = (byte) (c[i] - '0'); switch (c[i++]) { case '.': ++j;//from ww w . j av a 2 s . c o m break; default: if ((d < 0) || (d > 9)) return 0; if ((b[j] & 0xff) * 10 + d > 255) return 0; b[j] = (byte) (b[j] * 10 + d); } } return 0x00000000ffffffffl & (b[0] << 24 | (b[1] & 0xff) << 16 | (b[2] & 0xff) << 8 | (b[3] & 0xff)); } }