Here you can find the source of IpToInt(String strIp)
public static int IpToInt(String strIp)
//package com.java2s; //License from project: Apache License public class Main { public static int IpToInt(String strIp) { int[] ip = new int[4]; int position1 = strIp.indexOf("."); int position2 = strIp.indexOf(".", position1 + 1); int position3 = strIp.indexOf(".", position2 + 1); ip[0] = Integer.parseInt(strIp.substring(0, position1)); ip[1] = Integer.parseInt(strIp.substring(position1 + 1, position2)); ip[2] = Integer.parseInt(strIp.substring(position2 + 1, position3)); ip[3] = Integer.parseInt(strIp.substring(position3 + 1)); return (ip[0] << 24) + (ip[1] << 16) + (ip[2] << 8) + ip[3]; }// w ww . ja va2 s .c om }