程序包 com.ajaxjs.util

类 EncodeTools


  • public class EncodeTools
    extends Object
    String URL/Base64 encoder
    • 字段详细资料

      • UTF8_SYMBOL

        public static final String UTF8_SYMBOL
        UTF-8 字符串而已
        另请参阅:
        常量字段值
    • 构造器详细资料

      • EncodeTools

        public EncodeTools()
    • 方法详细资料

      • urlChinese

        public static String urlChinese​(String str)
        URL 网址的中文乱码处理。 如果 Tomcat 过滤器设置了 UTF-8 那么这里就不用重复转码了
        参数:
        str - 通常是 URL 的 Query String 参数
        返回:
        中文
      • urlEncodeQuery

        public static String urlEncodeQuery​(String str)
        URL 编码。 适合 GET 请求时候用

        ...

        参数:
        str - 输入的字符串
        返回:
        编码后的字符串
      • urlEncode

        public static String urlEncode​(String str)
        URL 编码
        参数:
        str - 输入的字符串
        返回:
        URL 编码后的字符串
      • urlDecode

        public static String urlDecode​(String str)
        URL 解码
        参数:
        str - 输入的字符串
        返回:
        URL 解码后的字符串
      • base64Encode

        public static byte[] base64Encode​(byte[] bytes)
        BASE64 编码 这是核心编码方法,无关编码
        参数:
        bytes - 待编码的字符串 bytes
        返回:
        已编码的字符串 bytes
      • base64EncodeToString

        public static String base64EncodeToString​(byte[] bytes)
        BASE64 编码
        参数:
        bytes - 待编码的字符串 bytes
        返回:
        已编码的字符串。使用 ISO-8859-1 字符集,请注意区别
      • base64EncodeToString

        public static String base64EncodeToString​(String str)
        BASE64 编码
        参数:
        str - 待编码的字符串,使用 ISO-8859-1 字符集,请注意区别
        返回:
        已编码的字符串。使用 ISO-8859-1 字符集,请注意区别
      • base64EncodeToStringUtf8

        public static String base64EncodeToStringUtf8​(byte[] bytes)
        BASE64 编码
        参数:
        bytes - 待编码的字符串 bytes
        返回:
        已编码的字符串。使用 UTF-8 字符集,请注意区别
      • base64EncodeToStringUtf8

        public static String base64EncodeToStringUtf8​(String str)
        BASE64 编码
        参数:
        str - 待编码的字符串,使用 UTF-8 字符集,请注意区别
        返回:
        已编码的字符串。使用 UTF-8 字符集,请注意区别
      • base64Decoder

        public static byte[] base64Decoder​(byte[] bytes)
        BASE64 解码 这是核心解码方法,无关编码
        参数:
        bytes - 待解码的字符串 bytes
        返回:
        已解码的字符串 bytes
      • base64Decode

        public static byte[] base64Decode​(String str)
        BASE64 解码
        参数:
        str - 待解码的字符串 bytes,使用 ISO-8859-1 字符集,请注意区别
        返回:
        已解码的字符串数据
      • base64DecodeToString

        public static String base64DecodeToString​(String str)
        BASE64 解码
        参数:
        str - 待解码的字符串 bytes,使用 ISO-8859-1 字符集,请注意区别
        返回:
        已解码的字符串数据
      • base64DecodeToStringUtf8

        public static String base64DecodeToStringUtf8​(byte[] bytes)
        BASE64 解码
        参数:
        bytes - 待解码的字符串 bytes
        返回:
        已解码的字符串。使用 UTF-8 字符集,请注意区别
      • base64DecodeToStringUtf8

        public static String base64DecodeToStringUtf8​(String str)
        BASE64 解码
        参数:
        str - 待解码的字符串,使用 UTF-8 字符集,请注意区别
        返回:
        已解码的字符串。使用 UTF-8 字符集,请注意区别