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 ( ) ; }
Get URL protocol - lower case or null if given URL does not contains one . Returns null if given URL argument is null or empty .