Here you can find the source of stringToIpAddress(String s)
public static int stringToIpAddress(String s)
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.UnknownHostException; import java.nio.ByteBuffer; public class Main { public static int stringToIpAddress(String s) { try {//from ww w . j av a2 s . com return ByteBuffer.wrap(InetAddress.getByName(s).getAddress()).getInt(); } catch (UnknownHostException e) { return -1; } } }