public int dnsDomainLevels(String host){
  int count=0;
  int startPos=0;
  while ((startPos=host.indexOf(".",startPos + 1)) > -1) {
    count++;
  }
  return count;
}

public int dnsDomainLevels ( String host ) { int count = 0 ; int startPos = 0 ; while ( ( startPos = host . indexOf ( "." , startPos + 1 ) ) > - 1 ) { count ++ ; } return count ; }
returns the number of dns domain levels ( number of dots ) in the host name .
