private static String[] extractHostports(SrvRecord[] srvRecords){
  String[] hostports=null;
  int head=0;
  int tail=0;
  int sublistLength=0;
  int k=0;
  for (int i=0; i < srvRecords.length; i++) {
    if (hostports == null) {
      hostports=new String[srvRecords.length];
    }
    head=i;
    while (i < srvRecords.length - 1 && srvRecords[i].priority == srvRecords[i + 1].priority) {
      i++;
    }
    tail=i;
    sublistLength=(tail - head) + 1;
    for (int j=0; j < sublistLength; j++) {
      hostports[k++]=selectHostport(srvRecords,head,tail);
    }
  }
  return hostports;
}

private static String [ ] extractHostports ( SrvRecord [ ] srvRecords ) { String [ ] hostports = null ; int head = 0 ; int tail = 0 ; int sublistLength = 0 ; int k = 0 ; for ( int i = 0 ; i < srvRecords . length ; i ++ ) { if ( hostports == null ) { hostports = new String [ srvRecords . length ] ; } head = i ; while ( i < srvRecords . length - 1 && srvRecords [ i ] . priority == srvRecords [ i + 1 ] . priority ) { i ++ ; } tail = i ; sublistLength = ( tail - head ) + 1 ; for ( int j = 0 ; j < sublistLength ; j ++ ) { hostports [ k ++ ] = selectHostport ( srvRecords , head , tail ) ; } } return hostports ; }
extract hosts and port numbers from a list of srv records . an array of hostports is returned or null if none were found .
