Java IP Address to Byte Array ipv4ToBytes(String ipv4)

Here you can find the source of ipv4ToBytes(String ipv4)

Description

ipv To Bytes

License

Apache License

Declaration

public static byte[] ipv4ToBytes(String ipv4) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static byte[] ipv4ToBytes(String ipv4) {
        String[] groups = ipv4.split("\\.");
        byte[] ret = new byte[4];
        for (int i = 0; i < 4; i++) {
            ret[i] = (byte) Integer.parseInt(groups[i]);
        }/*from  ww  w  .  j  av a 2  s.  com*/
        return ret;
    }
}

Related

  1. ipToByte(String ip)
  2. IpToBytes(String ip)
  3. ipToBytesByReg(String ipAddr)
  4. ipv4StringToByteArrayUnchecked(String str)
  5. ipv4ToBinary(String ip)
  6. ipv4ToBytes(String ipv4)