java编码转换url

时间:2021-09-30 15:59:01
package com.comtop.log;
import java.util.HashSet;
import java.util.Iterator;
/**
 *最近发现weblogic堵塞的线程是乱码,于是想转换一下
 *字符转换
 */
public class EscapeCodeUrl {
    public static void main(String args[]) throws Exception{
        String url[] ={"/web/pro%E5%8F%96%E7%88%B6%E9%A1%B5%E9%9D%A2%E8%AE%B0%E5%BD%95mask%E5%8F%82%E6%95%B0%E7%9A%84%E5%AD%97%E6%AE%B5%202009-12-05%20liuzhuangdocument.noteStructureForm.submit();%20%20%20%20%20%20%20%20%7D%20%20%20%20%7D//%E6%96%B0%E5%A2%9Efunction%20insert()%7Bvar%20isChildNote%20=noteStructureForm.isChildNote.value;if('1'%20==%20isChildNote)%7Balert("
            ,"
/web/produc%20%E8%BF%94%E5%9B%9Eform%E7%9A%84%E5%BD%93%E5%89%8D%E7%8A%B6%E6%80%81%20%20%20%20%20*%20%E8%AF%B4%E6%98%8E%EF%BC%9A%E7%94%A8%E6%88%B7%E5%8F%AF%E4%BB%A5%E9%80%9A%E8%BF%87%E8%AF%A5%E7%8A%B6%E6%80%81%E5%86%B3%E5%AE%9A%E7%A8%8B%E5%BA%8F%E7%9A%84%E6%B5%81%E7%A8%8B%E8%B5%B0%E5%90%91%20%20%20%20%20*%20@param%20form%20%E6%89%80%E6%A3%80%E6%9F%A5%E7%9A%84form%E5%AF%B9%E8%B1%A1%20%20%20%20%20*%20@return%20ture%20form%E6%94%B9%E5%8F%98%EF%BC%8Ctrue%20form%E6%B2%A1%E6%94%B9%E5%8F%98%20%20%20%20%20*/%20%20%20%20function%20getFormStatus(form)%20%7B%20%20%20%20%20%20%20return%20isFormChanged(form);%20%20%20%20%7D//%E5%80%BC%E5%8F%98%E5%8C%96%E6%97%B6%E8%A7%A6%E5%8F%91%E7%9A%84%E4%BA%8B%E4%BB%B6function%20initChangeValue()%7B//%E5%A6%82%E6%9E%9C%E4%B8%8D%E5%AD%98%E5%9C%A8%E9%9C%80%E8%A6%81%E8%AE%A1%E7%AE%97%E7%9A%84%E5%AD%97%E6%AE%B5%EF%BC%8C%E8%BF%94%E5%9B%9Eif(document.getElementById(deviceNo+%22ActionTimes1%22)==null)%7Breturn;%7D//%E8%AE%B0%E5%BD%95%E7%B0%BF%E5%90%8D%E7%A7%B0var%20noteNo=document.noteStructureForm.noteNo.value;//%E8%AE%BE%E5%A4%87%E7%BC%96%E5%8F%B7%E5%AF%B9%E5%BA%94%E5%AD%97%E6%AE%B5%E5%90%8D%E7%A7%B0var%20deviceCode=document.getElementById(deviceNo+%22Code%22).name;//%E8%AE%BE%E5%A4%87%E7%BC%96%E5%8F%B7%E5%AF%B9%E5%BA%94%E7%9A%84%E5%80%BC%EF%BC%8C%E5%8D%B3%E8%AE%BE%E5%A4%87%E7%BC%96%E5%8F%B7var%20deviceFieldValue=document.getElementById(deviceNo+%22Code%22).value;//%E8%AE%BE%E5%A4%87%E7%BC%96%E5%8F%B7%E5%9C%A8%E8%AE%B0%E5%BD%95%E7%B0%BF%E4%B8%AD%E5%AF%B9%E5%BA%94%E7%9A%84%E7%BC%96%E5%8F%B7var%20deviceFieldNumber=deviceCode.substring(noteNo.length+1,deviceCode.length);//%E4%B8%8A%E6%AC%A1%E6%A3%80%E4%BF%AE%E6%97%B6%E9%97%B4priorTime=document.getElementById(deviceNo+%22PriorTime%22).name;//%E4%B8%8A%E6%AC%A1%E6%A3%80%E4%BF%AE%E6%97%B6%E9%97%B4%E5%9C%A8%E8%AE%B0%E5%BD%95%E7%B0%BF%E4%B8%AD%E5%AF%B9%E5%BA%94%E7%9A%84%E7%BC%96%E5%8F%B7var%20priorTimeFieldNumber%20=%20priorTime.substring(noteNo.length+1,PriorTime.length);var%20iCount%20=%201;vartotalTimes%20%20=%20document.getElementById(deviceNo+%22TotalTimes%22+iCount);var%20fieldNumberStr%20 ="
            ,"/web/pro%E5%8F%96%E7%88%B6%E9%A1%B5%E9%9D%A2%E8%AE%B0%E5%BD%95mask%E5%8F%82%E6%95%B0%E7%9A%84%E5%AD%97%E6%AE%B5%202009-12-05%20liuzhuangdocument.noteStructureForm.submit();%20%20%20%20%20%20%20%20%7D%20%20%20%20%7D//%E6%96%B0%E5%A2%9Efunction%20insert()%7Bvar%20isChildNote%20=noteStructureForm.isChildNote.value;if('1'%20==%20isChildNote)%7Balert("
            ,"/web/pro%E5%8F%96%E7%88%B6%E9%A1%B5%E9%9D%A2%E8%AE%B0%E5%BD%95mask%E5%8F%82%E6%95%B0%E7%9A%84%E5%AD%97%E6%AE%B5%202009-12-05%20liuzhuangdocument.noteStructureForm.submit();%20%20%20%20%20%20%20%20%7D%20%20%20%20%7D//%E6%96%B0%E5%A2%9Efunction%20insert()%7Bvar%20isChildNote%20=noteStructureForm.isChildNote.value;if('1'%20==%20isChildNote)%7Balert("
            ,"/web/pro%E5%8F%96%E7%88%B6%E9%A1%B5%E9%9D%A2%E8%AE%B0%E5%BD%95mask%E5%8F%82%E6%95%B0%E7%9A%84%E5%AD%97%E6%AE%B5%202009-12-05%20liuzhuangdocument.noteStructureForm.submit();%20%20%20%20%20%20%20%20%7D%20%20%20%20%7D//%E6%96%B0%E5%A2%9Efunction%20insert()%7Bvar%20isChildNote%20=noteStructureForm.isChildNote.value;if('1'%20==%20isChildNote)%7Balert("};
        String encoding = "utf-8";
        HashSet set = new HashSet();
        for(int i=0; i< url.length; i++){
            set.add(java.net.URLDecoder.decode (url[i],encoding));
        }
        Iterator it=set.iterator();
        while(it.hasNext()) {
          System.out.println(it.next());
        }
}