Java URI Encode encodeURIComponent(final String s)

Here you can find the source of encodeURIComponent(final String s)

Description

encode URI Component

License

Apache License

Declaration

public static final String encodeURIComponent(final String s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {

    public static final String encodeURIComponent(final String s) {
        if (s == null || s.length() == 0) {
            return s;
        }//w  ww.ja v a  2  s .c om
        try {
            return URLEncoder.encode(s, "utf-8");// StrFunc.UTF8
        } catch (UnsupportedEncodingException ex) {
            throw new RuntimeException(ex);
        }
    }
}

Related

  1. encodeURI(String uri)
  2. encodeUri(String uri)
  3. encodeUri(String uri)
  4. encodeUri(URI uri)
  5. encodeURI(URI uri)
  6. encodeURIComponent(String component)
  7. encodeURIComponent(String input)
  8. encodeURIComponent(String s, String charset)
  9. encodeURIComponent(String uriComp)