private void getInterfaceInfo ( NetworkInterface networkInterface , PrintWriter out ) throws IOException { final String indent = " " ; // Basic information from the interface out . println ( ) ; out . append ( "Interface: " ) . append ( networkInterface . getDisplayName ( ) ) . println ( ) ; out . append ( indent ) . append ( " loopback: " ) . append ( Boolean . toString ( networkInterface . isLoopback ( ) ) ) . println ( ) ; out . append ( indent ) . append ( " mtu: " ) . append ( Integer . toString ( networkInterface . getMTU ( ) ) ) . println ( ) ; out . append ( indent ) . append ( " point-to-point: " ) . append ( Boolean . toString ( networkInterface . isPointToPoint ( ) ) ) . println ( ) ; out . append ( indent ) . append ( "supports multicast: " ) . append ( Boolean . toString ( networkInterface . supportsMulticast ( ) ) ) . println ( ) ; out . append ( indent ) . append ( " up: " ) . append ( Boolean . toString ( networkInterface . isUp ( ) ) ) . println ( ) ; out . append ( indent ) . append ( " virtual: " ) . append ( Boolean . toString ( networkInterface . isVirtual ( ) ) ) . println ( ) ; // Interface address information List < InterfaceAddress > intfAddresses = networkInterface . getInterfaceAddresses ( ) ; for ( int i = 0 ; i < intfAddresses . size ( ) ; i ++ ) { out . append ( indent ) . append ( "InterfaceAddress #" ) . append ( Integer . toString ( i + 1 ) ) . append ( ": " ) . append ( String . valueOf ( intfAddresses . get ( i ) ) ) . println ( ) ; } // Network interface information Enumeration < InetAddress > inetAddresses = networkInterface . getInetAddresses ( ) ; for ( int i = 1 ; inetAddresses . hasMoreElements ( ) ; i ++ ) { InetAddress inetAddress = inetAddresses . nextElement ( ) ; out . append ( indent ) . append ( "InetAddress #" ) . append ( Integer . toString ( i ) ) . println ( ":" ) ; out . append ( indent ) . append ( indent ) . append ( " IP address: " ) . append ( inetAddress . getHostAddress ( ) ) . println ( ) ; out . append ( indent ) . append ( indent ) . append ( " host name: " ) . append ( inetAddress . getHostName ( ) ) . println ( ) ; out . append ( indent ) . append ( indent ) . append ( "FQDN host name: " ) . append ( inetAddress . getCanonicalHostName ( ) ) . println ( ) ; } }
Capture interface specific information and write it to the provided writer .