question: private static String formatAddress ( InterfaceAddress interfaceAddress ) throws IOException { StringBuilder sb = new StringBuilder ( ) ; InetAddress address = interfaceAddress . getAddress ( ) ; if ( address instanceof Inet6Address ) { sb . append ( "inet6 " ) ; sb . append ( NetworkAddress . formatAddress ( address ) ) ; sb . append ( " prefixlen:" ) ; sb . append ( interfaceAddress . getNetworkPrefixLength ( ) ) ; } else { sb . append ( "inet " ) ; sb . append ( NetworkAddress . formatAddress ( address ) ) ; int netmask = 0xFFFFFFFF << ( 32 - interfaceAddress . getNetworkPrefixLength ( ) ) ; sb . append ( " netmask:" + NetworkAddress . formatAddress ( InetAddress . getByAddress ( new byte [ ] { ( byte ) ( netmask > > > 24 ) , ( byte ) ( netmask > > > 16 & 0xFF ) , ( byte ) ( netmask > > > 8 & 0xFF ) , ( byte ) ( netmask & 0xFF ) } ) ) ) ; InetAddress broadcast = interfaceAddress . getBroadcast ( ) ; if ( broadcast != null ) { sb . append ( " broadcast:" + NetworkAddress . formatAddress ( broadcast ) ) ; } } if ( address . isLoopbackAddress ( ) ) { sb . append ( " scope:host" ) ; } else if ( address . isLinkLocalAddress ( ) ) { sb . append ( " scope:link" ) ; } else if ( address . isSiteLocalAddress ( ) ) { sb . append ( " scope:site" ) ; } return sb . toString ( ) ; }
target:  format internet address: java's default doesn't include everything useful 