public static InetAddress decrement ( InetAddress address ) { byte [ ] addr = address . getAddress ( ) ; int i = addr . length - 1 ; while ( i >= 0 && addr [ i ] == ( byte ) 0x00 ) { addr [ i ] = ( byte ) 0xff ; i -- ; } checkArgument ( i >= 0 , "Decrementing %s would wrap." , address ) ; addr [ i ] -- ; return bytesToInetAddress ( addr ) ; }
Returns a new InetAddress that is one less than the passed in address . This method works for both IPv4 and IPv6 addresses .