Java IP Address to Byte Array ipToByte(String ip)

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

Description

ip To Byte

License

Open Source License

Declaration

private static int[] ipToByte(String ip) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static int[] ipToByte(String ip) {
        int[] result = new int[4];
        String[] ipPart = ip.split("\\.");
        result[0] = Integer.parseInt(ipPart[0]);
        result[1] = Integer.parseInt(ipPart[1]);
        result[2] = Integer.parseInt(ipPart[2]);
        result[3] = Integer.parseInt(ipPart[3]);

        return result;
    }//w w  w . java  2  s. c o  m
}

Related

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