Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.devbliss.doctest.utils;
 
 import java.net.URI;

Helper class which deals with java.net.URI objects

Author(s):
bmary
public class UriHelper {

    
Transforms a java.net.URI object to a string containing only the following informations:
  • path
  • parameters

Parameters:
uri
Returns:
    public String uriToString(URI uri) {
        StringBuffer buffer = new StringBuffer();
        if (uri != null) {
            if (uri.getPath().isEmpty()) {
                buffer.append("/");
            } else {
                buffer.append(uri.getPath());
            }
            if (uri.getQuery() != null) {
                buffer.append("?");
                buffer.append(uri.getQuery());
            }
        }
        return buffer.toString();
    }
New to GrepCode? Check out our FAQ X