当前位置: 首页>>代码示例>>Java>>正文


Java URLDecoder类代码示例

本文整理汇总了Java中jodd.util.URLDecoder的典型用法代码示例。如果您正苦于以下问题:Java URLDecoder类的具体用法?Java URLDecoder怎么用?Java URLDecoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


URLDecoder类属于jodd.util包,在下文中一共展示了URLDecoder类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decodeUri

import jodd.util.URLDecoder; //导入依赖的package包/类
public static String decodeUri(String src) {
    if (StringUtil.isEmpty(src)) {
        return src;
    }
    try {
        return URLDecoder.decode(src, "UTF-8");
    } catch (Exception e) {
        return src;
    }
}
 
开发者ID:febit,项目名称:febit-common,代码行数:11,代码来源:HttpUtil.java

示例2: parseQuery

import jodd.util.URLDecoder; //导入依赖的package包/类
/**
 * Parses query from give query string. Values are optionally decoded.
 */
public static HttpMultiMap<String> parseQuery(String query, boolean decode) {

	HttpMultiMap<String> queryMap = HttpMultiMap.newCaseInsensitveMap();

	int ndx, ndx2 = 0;
	while (true) {
		ndx = query.indexOf('=', ndx2);
		if (ndx == -1) {
			if (ndx2 < query.length()) {
				queryMap.add(query.substring(ndx2), null);
			}
			break;
		}
		String name = query.substring(ndx2, ndx);
		if (decode) {
			name = URLDecoder.decodeQuery(name);
		}

		ndx2 = ndx + 1;

		ndx = query.indexOf('&', ndx2);

		if (ndx == -1) {
			ndx = query.length();
		}

		String value = query.substring(ndx2, ndx);

		if (decode) {
			value = URLDecoder.decodeQuery(value);
		}

		queryMap.add(name, value);

		ndx2 = ndx + 1;
	}

	return queryMap;
}
 
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:43,代码来源:HttpUtil.java

示例3: toFileName

import jodd.util.URLDecoder; //导入依赖的package包/类
/**
 * Converts file URLs to file name. Accepts only URLs with 'file' protocol.
 * Otherwise, for other schemes returns <code>null</code>.
 */
public static String toFileName(URL url) {
	if ((url == null) || !(url.getProtocol().equals("file"))) {
		return null;
	}
	String filename = url.getFile().replace('/', File.separatorChar);

	return URLDecoder.decode(filename, JoddCore.encoding);
}
 
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:13,代码来源:FileUtil.java

示例4: decodeUri

import jodd.util.URLDecoder; //导入依赖的package包/类
public static String decodeUri(String src) {
    return URLDecoder.decode(src, "UTF-8");
}
 
开发者ID:febit,项目名称:febit-common,代码行数:4,代码来源:StringUtil.java

示例5: getTaoLongURL

import jodd.util.URLDecoder; //导入依赖的package包/类
public static String getTaoLongURL(String duanURL)throws Exception{
   HttpRequest httpRequest = null;
  	 httpRequest = HttpRequest.get(duanURL).timeout(20000);
 httpRequest.header("Content-Type", "application/json");
 httpRequest.header("User-Agent", HttpTest.getUserAgent());
 
 //HttpBrowser browser = new HttpBrowser();
 //HttpResponse response = browser.sendRequest(httpRequest);
 
 HttpResponse response = httpRequest.send();
 String location = response.header("Location");
// System.out.println(location);
 
 Thread.sleep(100);
 httpRequest.set(location);
 response = httpRequest.send();
 String location2 = response.header("Location");
 location2 = URLDecoder.decode(location2);
 //System.out.println(location2);

 
 String addStr = "&ref=&et=";
 
 URL url = new URL(location2);
 String queryStr = url.getQuery();
 for(String q:queryStr.split("\\&")){
	 if(StringUtils.isNotBlank(q) && q.startsWith("et")){
		 addStr = addStr + q.split("\\=")[1];
		 break;
	 }
 }
 
 String nowURL = location + addStr;
// System.out.println("newURL =="+nowURL);
 
 Thread.sleep(100);
 httpRequest.set(nowURL);
 httpRequest.header("Referer", location2);
 response = httpRequest.send();
 location2 = response.header("Location");
// System.out.println(location2);
 
/* response.charset("gbk");
 System.out.println(response.bodyText());*/
 
 
 return location2;
}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:49,代码来源:MatcherUtil.java


注:本文中的jodd.util.URLDecoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。