public static String extractAddressFromUrl(String url){
  String urlToProcess=null;
  int protocolEndIndex=url.indexOf("://");
  if (protocolEndIndex > 0) {
    urlToProcess=url.substring(protocolEndIndex + 3);
  }
 else {
    urlToProcess=url;
  }
  int pos=urlToProcess.indexOf(':');
  if (pos >= 0) {
    urlToProcess=urlToProcess.substring(0,pos);
  }
  pos=urlToProcess.indexOf('/');
  if (pos >= 0) {
    urlToProcess=urlToProcess.substring(0,pos);
  }
  pos=urlToProcess.indexOf('?');
  if (pos >= 0) {
    urlToProcess=urlToProcess.substring(0,pos);
  }
  return urlToProcess;
}

public static String extractAddressFromUrl ( String url ) { String urlToProcess = null ; int protocolEndIndex = url . indexOf ( "://" ) ; if ( protocolEndIndex > 0 ) { urlToProcess = url . substring ( protocolEndIndex + 3 ) ; } else { urlToProcess = url ; } int pos = urlToProcess . indexOf ( ':' ) ; if ( pos >= 0 ) { urlToProcess = urlToProcess . substring ( 0 , pos ) ; } pos = urlToProcess . indexOf ( '/' ) ; if ( pos >= 0 ) { urlToProcess = urlToProcess . substring ( 0 , pos ) ; } pos = urlToProcess . indexOf ( '?' ) ; if ( pos >= 0 ) { urlToProcess = urlToProcess . substring ( 0 , pos ) ; } return urlToProcess ; }
this method extracts from address the hostname
