Here you can find the source of ipv4ToBinary(String ip)
public static byte[] ipv4ToBinary(String ip)
//package com.java2s; //License from project: Apache License import java.net.InetAddress; public class Main { public static byte[] ipv4ToBinary(String ip) { try {/*from w w w . j a va 2 s .c o m*/ return InetAddress.getByName(ip).getAddress(); } catch (Exception e) { return new byte[4]; } } }