试试 java.net.URLDecoder.decode("your String");

解决方案 »

  1.   

    可参加jarkatar-commons项目的codec子项目
      

  2.   

    目前 Jakarta Commons Codec已经提供 base64, hex, 及 metaphone, soundex 等编码. 下载位置为: 
    http://jakarta.apache.org/commons/codec/index.html 
    Base64 编解码 base64 编解码技术广泛地利用在 Internet 之上, 主要就是将 bytecode 转换成 ascii 码, 最常常使用的则是属于电子邮件附件的传输. 你可以查看你的邮件原码, 如果有 Content-Transfer-Encoding: base64 , 就代表这封信有采用 base64 来编码, 另外则是 QP ( quoted-printable ) 编码方式, 基本上大多数的读信软件都有支持. package com.softleader.sample.codec;import org.apache.commons.codec.binary.Base64;
    import org.apache.commons.codec.*;public class Base64Test {    public static void main(String args[]) {
            Base64 base64 = new Base64();
            String str = "中文";
            byte[] enbytes = null;
            String encodeStr = null;
            byte[] debytes = null;
            String decodeStr = null;
            try {
                enbytes = base64.encode(str.getBytes());
                encodeStr = new String(enbytes);
                debytes = base64.decode(enbytes);
                decodeStr = new String(debytes);
            } catch (EncoderException ex) {
                System.out.println("编码错误");
            } catch (DecoderException ex) {
                System.out.println("解码错误");
            }
            System.out.println("编码前:"+str);
            System.out.println("编码后:"+encodeStr);
            System.out.println("解码后:"+decodeStr);
        }
    }cmd>java com.softleader.sample.codec.Base64Test
    执行结果
    编码前:中文
    编码后:pKSk5Q==
    解码后:中文