Java IP Address Convert To convertIPAdressToBytes(String ip)

Here you can find the source of convertIPAdressToBytes(String ip)

Description

convert IP Adress To Bytes

License

Open Source License

Declaration

static byte[] convertIPAdressToBytes(String ip) 

Method Source Code

//package com.java2s;
/*/*from   w w  w .  j  ava 2s  .c o m*/
 * Copyright (c) 2014, 2017 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[] convertIPAdressToBytes(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;
    }
}

Related

  1. convertIp(String ip)
  2. convertIP6Address(byte[] bytes)
  3. convertIpPortToUniqueId(byte[] quad, int port)
  4. convertIpv4Address(String ip)
  5. convertIpv4AddressToString(byte[] ipv4Address)
  6. convertIPv4NetworkPrefixLength(short length)