public static int createIpAddress ( byte [ ] address , char [ ] buffer ) { if ( isIpv4 ( address ) ) { return createIpv4Address ( address , 0 , buffer , 0 ) ; } int offset = 0 ; boolean isZeroCompress = false ; boolean isInZeroCompress = false ; buffer [ offset ++ ] = ' ' ; for ( int i = 0 ; i < 16 ; i += 2 ) { int value = ( address [ i ] & 0xff ) * 256 + ( address [ i + 1 ] & 0xff ) ; if ( value == 0 && i != 14 ) { if ( isInZeroCompress ) continue ; else if ( ! isZeroCompress ) { isZeroCompress = true ; isInZeroCompress = true ; continue ; } } if ( isInZeroCompress ) { isInZeroCompress = false ; buffer [ offset ++ ] = ' ' ; buffer [ offset ++ ] = ' ' ; } else if ( i != 0 ) { buffer [ offset ++ ] = ' ' ; } if ( value == 0 ) { buffer [ offset ++ ] = ' ' ; continue ; } offset = writeHexDigit ( buffer , offset , value >> 12 ) ; offset = writeHexDigit ( buffer , offset , value >> 8 ) ; offset = writeHexDigit ( buffer , offset , value >> 4 ) ; offset = writeHexDigit ( buffer , offset , value ) ; } buffer [ offset ++ ] = ' ' ; return offset ; }
Convert a system ip address to an actual address .