Java Charset Create getEncodedUrl(String unEncodedUrl)

Here you can find the source of getEncodedUrl(String unEncodedUrl)

Description

get Encoded Url

License

Apache License

Declaration

public static String getEncodedUrl(String unEncodedUrl) 

Method Source Code


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

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

public class Main {
    private static final String ERR_ENCODE_STRING = "Could not encode url";

    public static String getEncodedUrl(String unEncodedUrl) {
        try {//from  w  w  w .  ja  va  2  s  .c o  m
            return URLEncoder.encode(unEncodedUrl, StandardCharsets.UTF_8.name());
        } catch (UnsupportedEncodingException ex) {
            return ERR_ENCODE_STRING;
        }
    }
}

Related

  1. getDefaultCharset()
  2. getDefaultCharset()
  3. getDefaultCharsetName()
  4. getDefaultSystemCharset()
  5. getEncodedStringLength(String str)
  6. getEncoder()
  7. getEncoder()
  8. getEncoder()
  9. getEncoder(String encoding)