public static URI setFragment ( final URI path , final String fragment ) { try { if ( path . getPath ( ) != null ) { return new URI ( path . getScheme ( ) , path . getUserInfo ( ) , path . getHost ( ) , path . getPort ( ) , path . getPath ( ) , path . getQuery ( ) , fragment ) ; } else { return new URI ( path . getScheme ( ) , path . getSchemeSpecificPart ( ) , fragment ) ; } } catch ( final URISyntaxException e ) { throw new RuntimeException ( e . getMessage ( ) , e ) ; } }
Create new URI with a given fragment .