本文整理汇总了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;
}
}
示例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;
}
示例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);
}
示例4: decodeUri
import jodd.util.URLDecoder; //导入依赖的package包/类
public static String decodeUri(String src) {
return URLDecoder.decode(src, "UTF-8");
}
示例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;
}