Code example for URI

Methods: getFragment, getHost, getPath, getPort, getQuery, getScheme, getUserInfo

0
     * @return The lengthened URI 
     */ 
    public static URI lengthenURI(URI orig, String anExtra) {
        String extra = anExtra;
        try { 
            StringBuilder path = new StringBuilder(orig.getPath());
            char lastChar = path.charAt(path.length() - 1);
            char firstChar = extra.charAt(0);
            if (isSeparator(firstChar)) {
                if (isSeparator(lastChar)) {
                    path.append(extra.substring(1));
                } else { 
                    path.append(extra);
                } 
            } else { 
                if (!isSeparator(lastChar)) {
                    path.append(SEPARATOR);
                } 
                path.append(extra);
            } 
 
            return new URI(orig.getScheme(), orig.getUserInfo(), orig.getHost(), orig.getPort(), path.toString(), orig.getQuery(), orig.getFragment());
        } catch (URISyntaxException ex) {
            return null; 
        } 
    }