public static String modifyURIScheme ( String uri , String newScheme ) { try { URI uriObj = new URI ( uri ) ; return uriToString ( URLUtils . modifyURIScheme ( uriObj , newScheme ) ) ; } catch ( URISyntaxException e ) { try { return ( new NetworkInterfaceURI ( uri ) ) . modifyURIScheme ( newScheme ) ; } catch ( IllegalArgumentException ne ) { throw new IllegalArgumentException ( ne . getMessage ( ) , ne ) ; } } }
Helper method for modifying URI scheme