关闭

url地址解码、保留小数点后面两位数字

254人阅读 评论(0) 收藏 举报
分类:



url地址解码类

package com.xd.intersys.actions;

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

public class URLTransform {

    public static void main(String[] args) {
        String strTest = "q=%28%2B%28%2B%28%28%28%28%2BContent%3A%22*%22%7E16%29%29%5E10.0%29%29%29+%2B%28OriginType%3Aapp+OR+OriginType%3Ajw+OR+OriginType%3Asp+OR+OriginType%3Alt+OR+OriginType%3Axw+OR+OriginType%3Abaokan+OR+OriginType%3Awz+OR+OriginType%3Azw+OR+OriginType%3Awx+OR+OriginType%3Atb+OR+OriginType%3Abk+OR+OriginType%3Awb+OR+OriginType%3Agt%29+-OriginType%3Amg%29&fq=Published%3A%5B2016-02-10T16%3A00%3A00Z+TO+2016-03-11T15%3A59%3A59Z%5D&fq=OriginType%3A%22wz%22&projectType=unkown&group=true&group.field=PublishedDay&group.format=grouped&group.main=false&group.cache.percent=50&rows=100&shards.tolerant=true&collection=collection02%2Ccollection03%2C]";
        /* strTest = URLEncoder.encode(strTest, "UTF-8"); */

        try {
            strTest = URLDecoder.decode(strTest, "UTF-8");
        } catch (UnsupportedEncodingException e) {

            e.printStackTrace();
        }
        System.out.println(strTest);
    }

}


保留小数点后面两位数

package com.xd.intersys.actions;

public class Snippet {
    public static void main(String[] args) {
        
    //两个整数相除结果转化为float    
    int a=5;
    int b=3;
    
    System.out.println((float) a/b);
    
    //保留小数点后两位
    java.text.DecimalFormat df=new java.text.DecimalFormat("#.##");
    double d=3.14159;
    System.out.println(df.format(d)+"%");
    }

    
}


本文出自 “点滴积累” 博客,请务必保留此出处http://tianxingzhe.blog.51cto.com/3390077/1750056

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:187651次
    • 积分:4648
    • 等级:
    • 排名:第6514名
    • 原创:342篇
    • 转载:27篇
    • 译文:0篇
    • 评论:8条
    文章存档