public static String reverseUrl(URL url){
  String host=url.getHost();
  String file=url.getFile();
  String protocol=url.getProtocol();
  int port=url.getPort();
  StringBuilder buf=new StringBuilder();
  reverseAppendSplits(host,buf);
  buf.append(':');
  buf.append(protocol);
  if (port != -1) {
    buf.append(':');
    buf.append(port);
  }
  if (file.length() > 0 && '/' != file.charAt(0)) {
    buf.append('/');
  }
  buf.append(file);
  return buf.toString();
}

public static String reverseUrl ( URL url ) { String host = url . getHost ( ) ; String file = url . getFile ( ) ; String protocol = url . getProtocol ( ) ; int port = url . getPort ( ) ; StringBuilder buf = new StringBuilder ( ) ; reverseAppendSplits ( host , buf ) ; buf . append ( ':' ) ; buf . append ( protocol ) ; if ( port != - 1 ) { buf . append ( ':' ) ; buf . append ( port ) ; } if ( file . length ( ) > 0 && '/' != file . charAt ( 0 ) ) { buf . append ( '/' ) ; } buf . append ( file ) ; return buf . toString ( ) ; }
reverses a url ' s domain . this form is better for storing in hbase . because scans within the same domain are faster . < p > e . g . " http : / / bar . foo . com : 8983 / to / index . html ? a = b " becomes " com . foo . bar : http : 8983 / to / index . html ? a = b " .
