Java UTF8 Encode utf8Encode(String url)

Here you can find the source of utf8Encode(String url)

Description

utf Encode

License

Apache License

Declaration

public static String utf8Encode(String url) 

Method Source Code


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

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

public class Main {
    public static String utf8Encode(String url) {
        return urlEncode(url, StandardCharsets.UTF_8);
    }/*from  w ww  . j  a  v a2s  .  c om*/

    public static String urlEncode(String url, Charset cs) {
        try {
            return URLEncoder.encode(url, cs.name());
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. utf8Encode(final String value)
  2. utf8Encode(String s)
  3. utf8Encode(String str)
  4. utf8Encode(String str)
  5. Utf8Encode(String string)
  6. utf8FromString(String sIn)
  7. utf8urlencode(String text)