private static byte[] ip4ToIp6(byte[] ip4){
  if (ip4.length != 4)   throw new IllegalArgumentException("IPv4 address must be four octets");
  byte[] ip6=new byte[16];
  for (int i=0; i < 16 - 4; i++)   ip6[i]=0;
  for (int i=0; i < 4; i++)   ip6[12 + i]=ip4[i];
  return ip6;
}

private static byte [ ] ip4ToIp6 ( byte [ ] ip4 ) { if ( ip4 . length != 4 ) throw new IllegalArgumentException ( "IPv4 address must be four octets" ) ; byte [ ] ip6 = new byte [ 16 ] ; for ( int i = 0 ; i < 16 - 4 ; i ++ ) ip6 [ i ] = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) ip6 [ 12 + i ] = ip4 [ i ] ; return ip6 ; }
convert an ipv4 address to an ipv6 ipv4 - compatible address .
