Here you can find the source of ipToInt(String ip)
public static int ipToInt(String ip)
//package com.java2s; //License from project: Apache License public class Main { public static int ipToInt(String ip) { if (ip == null) return 0; char[] chars = ip.toCharArray(); int i1, i2, i3; for (i1 = 0; i1 < chars.length && chars[i1] != '.'; i1++) ;//from w w w.ja va2s .co m for (i2 = i1 + 1; i2 < chars.length && chars[i2] != '.'; i2++) ; for (i3 = i2 + 1; i3 < chars.length && chars[i3] != '.'; i3++) ; return (Integer.parseInt(ip.substring(0, i1), 10) << 24) | (Integer.parseInt(ip.substring(i1 + 1, i2), 10) << 16) | (Integer.parseInt(ip.substring(i2 + 1, i3), 10) << 8) | Integer.parseInt(ip.substring(i3 + 1, chars.length), 10); } }