java urldecode笔记
来源:互联网 发布:青果教育网络管理系统 编辑:程序博客网 时间:2024/05/22 21:17
package com.util;
import java.io.UnsupportedEncodingException;
/**
* url转码、解码
*
* @author zhuan
* @date 2015-3-17 下午04:09:35
*/
public class UrlUtil {
private final static String ENCODE = "UTF-8";
/**
* URL 解码
*
* @return String
* @author zhuan
* @date 2015-3-17 下午04:09:51
*/
public static String getURLDecoderString(String str) {
String result = "";
if (null == str) {
return "";
}
try {
result = java.net.URLDecoder.decode(str, ENCODE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
/**
* URL 转码
*
* @return String
* @author zhuan
* @date 2015-3-17 下午04:10:28
*/
public static String getURLEncoderString(String str) {
String result = "";
if (null == str) {
return "";
}
try {
result = java.net.URLEncoder.encode(str, ENCODE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
/**
*
* @return void
* @author zhuan
* @date 2015-3-17 下午04:09:16
*/
public static void main(String[] args) {
String str = "中文\001 1";
System.out.println(getURLEncoderString(str));
System.out.println(getURLDecoderString(str));
}
}
import java.io.UnsupportedEncodingException;
/**
* url转码、解码
*
* @author zhuan
* @date 2015-3-17 下午04:09:35
*/
public class UrlUtil {
private final static String ENCODE = "UTF-8";
/**
* URL 解码
*
* @return String
* @author zhuan
* @date 2015-3-17 下午04:09:51
*/
public static String getURLDecoderString(String str) {
String result = "";
if (null == str) {
return "";
}
try {
result = java.net.URLDecoder.decode(str, ENCODE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
/**
* URL 转码
*
* @return String
* @author zhuan
* @date 2015-3-17 下午04:10:28
*/
public static String getURLEncoderString(String str) {
String result = "";
if (null == str) {
return "";
}
try {
result = java.net.URLEncoder.encode(str, ENCODE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
/**
*
* @return void
* @author zhuan
* @date 2015-3-17 下午04:09:16
*/
public static void main(String[] args) {
String str = "中文\001 1";
System.out.println(getURLEncoderString(str));
System.out.println(getURLDecoderString(str));
}
}
阅读全文
0 0
- java urldecode笔记
- UrlDecode
- urldecode
- urldecode
- java中URLEncode和URLDecode
- php urlencode()与urldecode()函数字符编码原理-笔记
- java.net.URLEncode编码 与 URLDecode解码问题
- java.net.URLEncode编码 与 URLDecode解码问题
- java.net.URLEncode编码 与 URLDecode解码问题
- java.net.URLEncode编码 与 URLDecode解码问题 -
- Java网络编程之URLEncode和URLDecode工具类
- java.net.URLEncode编码 与 URLDecode解码问题
- java.net.URLEncode编码 与 URLDecode解码问题
- UrlEncode UrlDecode
- urlencode urldecode
- urlencode,urldecode
- urldecode.php
- HttpUtility.UrlDecode Server.UrlDecode 区别
- pyhotn3入门基础-11 生成器
- 第四十篇:GCD 多线程
- APK包的安装,卸载和优化
- Java中连续继承中的多态问题
- X-frame-options头为设置
- java urldecode笔记
- C#——面向对象——静态成员和静态类——静态成员
- 程序员:如何写出杀手级简历
- Android数据库sqlite基本使用增、删、改、查
- MATLAB RGB to Gray
- 【Bootstrap】表格的CSS布局
- java.math.RoundingMode 几个参数详解
- poll
- linux crontab & 每隔10秒执行一次