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

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

Go to download

Alibaba Cloud Credentials for Java Copyright (C) Alibaba Cloud Computing All rights reserved. 版权所有 (C)阿里云计算有限公司 https://www.aliyun.com

There is a newer version: 0.3.12
Show newest version
package com.aliyun.credentials.utils;

import com.aliyun.credentials.exception.CredentialException;

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