code: public static String getProtocol(String url)
    {
      if(url == null) {
        return null;
      }
      int protocolSeparatorIndex = url.indexOf("://");
      if(protocolSeparatorIndex == -1) {
        return null;
      }
      return url.substring(0, protocolSeparatorIndex).toLowerCase();
    }
docs: Get URL protocol - lower case, or null if given URL does not contains one. Returns null if given URL argument is
  null or empty.
  
  @param url URL to retrieve the protocol.
  @return lower case URL protocol, possible null.