Here you can find the source of textToNumericFormatV4(String ipString)
private static byte[] textToNumericFormatV4(String ipString)
//package com.java2s; //License from project: Apache License public class Main { private static final int IPV4_PART_COUNT = 4; private static byte[] textToNumericFormatV4(String ipString) { String[] address = ipString.split("\\.", IPV4_PART_COUNT + 1); if (address.length != IPV4_PART_COUNT) { return null; }/*from w ww . jav a 2 s . com*/ byte[] bytes = new byte[IPV4_PART_COUNT]; try { for (int i = 0; i < bytes.length; i++) { bytes[i] = parseOctet(address[i]); } } catch (NumberFormatException ex) { return null; } return bytes; } private static byte parseOctet(String ipPart) { int octet = Integer.parseInt(ipPart); if (octet > 255 || (ipPart.startsWith("0") && ipPart.length() > 1)) { throw new NumberFormatException(); } return (byte) octet; } }