public static String [ ] parseProxy ( String proxy , List < String > errors ) { String [ ] parsedProxyInfo = new String [ 4 ] ; if ( proxy != null ) { try { URL proxyAsUrl = new URL ( proxy ) ; parsedProxyInfo [ 0 ] = proxyAsUrl . getHost ( ) ; parsedProxyInfo [ 1 ] = String . valueOf ( proxyAsUrl . getPort ( ) ) ; if ( proxyAsUrl . getUserInfo ( ) != null ) { String [ ] parsedCred = proxyAsUrl . getUserInfo ( ) . split ( COLON ) ; parsedProxyInfo [ 2 ] = parsedCred [ 0 ] ; if ( parsedCred . length > 1 ) { parsedProxyInfo [ 3 ] = parsedCred [ 1 ] ; } } } catch ( MalformedURLException e ) { errors . add ( "Malformed proxy url : {}" + e . getMessage ( ) ) ; } } return parsedProxyInfo ; }
returns data of proxy url from command line parameter proxy