Java String Encode by Charset urlEncode(String url, Charset cs)

Here you can find the source of urlEncode(String url, Charset cs)

Description

url Encode

License

Apache License

Declaration

public static String urlEncode(String url, Charset cs) 

Method Source Code


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

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.Charset;

public class Main {
    public static String urlEncode(String url, Charset cs) {
        try {/*from   w  ww.ja va2  s .com*/
            return URLEncoder.encode(url, cs.name());
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. getHeader(Charset encoding)
  2. loadAsString(String locationPattern, Charset encoding)
  3. pathEncode(String path, Charset charset)
  4. urlEncode(final String content, final Charset charset, final BitSet safechars, final boolean blankAsPlus)
  5. urlEncode(final String str, final Charset encoding)