Here you can find the source of IpToBytes(String ip)
static byte[] IpToBytes(String ip)
//package com.java2s; /*// w w w . j ava2 s . c o m * Copyright (c) 2014 ConteXtream Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ public class Main { static byte[] IpToBytes(String ip) { String[] ipStr = ip.split("\\."); byte[] bytes = new byte[ipStr.length]; for (int i = 0; i < ipStr.length; i++) { bytes[i] = Integer.valueOf(ipStr[i], 10).byteValue(); } return bytes; } }