static byte[] getIpv4Bytes(String ipv4) {
    byte[] result = new byte[4];
    int pos = 0;
    for (int i = 0, len = ipv4.length(); i < len; ) {
      char ch = ipv4.charAt(i++);
      int octet = ch - '0';
      if (i == len || (ch = ipv4.charAt(i++)) == '.') {
        // then we have a single digit octet
        result[pos++] = (byte) octet;
        continue;
      }
      // push the decimal
      octet = (octet * 10) + (ch - '0');
      if (i == len || (ch = ipv4.charAt(i++)) == '.') {
        // then we have a two digit octet
        result[pos++] = (byte) octet;
        continue;
      }
      // otherwise, we have a three digit octet
      octet = (octet * 10) + (ch - '0');
      result[pos++] = (byte) octet;
      i++; // skip the dot
    }
    return result;
  }
Adapted from code in {@code com.google.common.net.InetAddresses.ipStringToBytes}. This version
separates detection from parsing and checks more carefully about embedded addresses.
zipkin/src/main/java/zipkin2/Endpoint.java