@ SuppressWarnings ( "rawtypes" ) private List < InetAddress > resolve ( String hostname , String attrName ) throws NamingException , UnknownHostException { Attributes attrs = context . getAttributes ( hostname , new String [ ] { attrName } ) ; List < InetAddress > inetAddresses = new ArrayList <> ( ) ; Attribute attr = attrs . get ( attrName ) ; if ( attr != null && attr . size ( ) > 0 ) { NamingEnumeration e = attr . getAll ( ) ; while ( e . hasMore ( ) ) { InetAddress inetAddress = InetAddress . getByName ( "" + e . next ( ) ) ; inetAddresses . add ( InetAddress . getByAddress ( hostname , inetAddress . getAddress ( ) ) ) ; } } return inetAddresses ; }
Resolve an attribute for a hostname .