Java URI Encode encodeURIComponent(String uriComp)

Here you can find the source of encodeURIComponent(String uriComp)

Description

encode URI Component

License

Open Source License

Declaration

public static String encodeURIComponent(String uriComp) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {
    public static String encodeURIComponent(String uriComp) {
        try {/*from w  w w.  jav  a  2  s  . c  o m*/
            return URLEncoder.encode(uriComp, "UTF-8").replaceAll("\\+", "%20");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Encoding URI component \"" + uriComp + "\" failed", e);
        }
    }
}

Related

  1. encodeURI(URI uri)
  2. encodeURIComponent(final String s)
  3. encodeURIComponent(String component)
  4. encodeURIComponent(String input)
  5. encodeURIComponent(String s, String charset)
  6. encodeUriComponent(String value)
  7. encodeURIComponentForJavaScript(String str)
  8. encodeURIParam(String s)
  9. encodeURIString(Writer out, String text, String encoding, int start)