All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aliyun.auth.credentials.utils.AcsURLEncoder Maven / Gradle / Ivy

The newest version!
package com.aliyun.auth.credentials.utils;

import com.aliyun.auth.credentials.exception.*;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class AcsURLEncoder {
    public final static String URL_ENCODING = "UTF-8";

    public static String encode(String value) {
        try {
            return URLEncoder.encode(value, URL_ENCODING);
        } catch (UnsupportedEncodingException e) {
            throw new CredentialException(e.getMessage(), e);
        }
    }

    public static String percentEncode(String value) {
        try {
            return value != null ? URLEncoder.encode(value, URL_ENCODING).replace("+", "%20")
                    .replace("*", "%2A").replace("%7E", "~") : null;
        } catch (UnsupportedEncodingException e) {
            throw new CredentialException(e.getMessage(), e);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy