本文整理汇总了Java中java.net.URLDecoder.decode方法的典型用法代码示例。如果您正苦于以下问题:Java URLDecoder.decode方法的具体用法?Java URLDecoder.decode怎么用?Java URLDecoder.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.URLDecoder
的用法示例。
在下文中一共展示了URLDecoder.decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExePath
import java.net.URLDecoder; //导入方法依赖的package包/类
/**
* https://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file
* @return path to the exe (without an exe). Example: "/E:/Eclipse/workspace/BHBot/bin/".
*/
public static String getExePath() {
try {
return URLDecoder.decode(ClassLoader.getSystemClassLoader().getResource(".").getPath(), "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
/*
try {
return (new File(Misc.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath())).getAbsolutePath();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
*/
}
示例2: parseRequestHeaderCookie
import java.net.URLDecoder; //导入方法依赖的package包/类
private static Map<String, String> parseRequestHeaderCookie(String requestHeaderCookie) {
Map<String, String> result = new TreeMap();
String name, value;
String[] cookies = requestHeaderCookie.split(";"), cookieParts;
for (String c : cookies) {
cookieParts = c.split("=");
if (cookieParts.length != 2)
continue;
try {
name = cookieParts[0].trim();
value = URLDecoder.decode(cookieParts[1].trim(), "UTF-8");
result.put(name, value);
}
catch (UnsupportedEncodingException e) {
} // UTF-8 is always supported
}
return result;
}
示例3: decode
import java.net.URLDecoder; //导入方法依赖的package包/类
/**
* Decodes the encoded String value using the specified encoding (such as UTF-8). It is assumed
* the String value was encoded with the URLEncoder using the specified encoding. This method
* handles UnsupportedEncodingException by just returning the encodedValue. Since it is possible
* for a String value to have been encoded multiple times, the String value is decoded until the
* value stops changing (in other words, until the value is completely decoded).
* <p/>
*
* @param encodedValue the encoded String value to decode.
* @param encoding a String value specifying the encoding.
* @return the decoded value of the String. If the encoding is unsupported, then the encodedValue
* is returned.
* @see java.net.URLDecoder
*/
public static String decode(String encodedValue, final String encoding) {
try {
if (encodedValue != null) {
String previousEncodedValue;
do {
previousEncodedValue = encodedValue;
encodedValue = URLDecoder.decode(encodedValue, encoding);
} while (!encodedValue.equals(previousEncodedValue));
}
return encodedValue;
} catch (UnsupportedEncodingException ignore) {
return encodedValue;
}
}
示例4: getSortParamsString
import java.net.URLDecoder; //导入方法依赖的package包/类
public static String getSortParamsString(String paramsString, boolean isDecode) {
StringBuilder sortParamsString = new StringBuilder("");
List<String> sortParamsNameList = getSortParamsName(paramsString);
Map<String, String> paramsMap = convertParamsString2Map(paramsString);
for (String paramName : sortParamsNameList) {
if (StringUtils.isNotEmpty(paramName)) {
if (StringUtils.isNotEmpty(sortParamsString.toString())) {
sortParamsString.append('&');
}
sortParamsString.append(paramName).append('=').append(paramsMap.get(paramName));
}
}
String result = null;
if (!isDecode) {
return sortParamsString.toString();
}
try {
result = URLDecoder.decode(sortParamsString.toString(), ENCODING_UTF8);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
示例5: asMap
import java.net.URLDecoder; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static Map<String, Object> asMap(String urlencoded, String encoding) throws UnsupportedEncodingException
{
Map<String, Object> map = new LinkedHashMap<>();
for (String keyValue : urlencoded.trim().split("&"))
{
String[] tokens = keyValue.trim().split("=");
String key = tokens[0];
String value = tokens.length == 1 ? null : URLDecoder.decode(tokens[1], encoding);
String[] keys = key.split("\\.");
Map<String, Object> pointer = map;
for (int i = 0; i < keys.length - 1; i++)
{
String currentKey = keys[i];
Map<String, Object> nested = (Map<String, Object>) pointer.get(keys[i]);
if (nested == null)
{
nested = new LinkedHashMap<>();
}
pointer.put(currentKey, nested);
pointer = nested;
}
pointer.put(keys[keys.length - 1], value);
}
return map;
}
示例6: urlDecode
import java.net.URLDecoder; //导入方法依赖的package包/类
@Nullable
private static String urlDecode(@NonNull String input) {
try {
return URLDecoder.decode(input, "UTF-8");
} catch (UnsupportedEncodingException e) {
return null;
}
}
示例7: testWithTPCCDDL
import java.net.URLDecoder; //导入方法依赖的package包/类
public void testWithTPCCDDL() {
String schemaPath = "";
try {
final URL url = TPCCClient.class.getResource("tpcc-ddl.sql");
schemaPath = URLDecoder.decode(url.getPath(), "UTF-8");
} catch (final UnsupportedEncodingException e) {
e.printStackTrace();
System.exit(-1);
}
final String simpleProject =
"<?xml version=\"1.0\"?>\n" +
"<project>" +
"<database name='database'>" +
"<schemas><schema path='" + schemaPath + "' /></schemas>" +
"<procedures><procedure class='org.voltdb.compiler.procedures.TPCCTestProc' /></procedures>" +
"</database>" +
"</project>";
//System.out.println(simpleProject);
final File projectFile = VoltProjectBuilder.writeStringToTempFile(simpleProject);
final String projectPath = projectFile.getPath();
final VoltCompiler compiler = new VoltCompiler();
final ClusterConfig cluster_config = new ClusterConfig(1, 1, 0, "localhost");
final boolean success = compiler.compile(projectPath, cluster_config,
"testout.jar", System.out, null);
assertTrue(success);
final File jar = new File("testout.jar");
jar.delete();
}
示例8: getInputGenerator
import java.net.URLDecoder; //导入方法依赖的package包/类
public RelationalInputGenerator getInputGenerator()
throws UnsupportedEncodingException, FileNotFoundException {
String
pathToInputFile =
URLDecoder.decode(
Thread.currentThread().getContextClassLoader().getResource(relationName).getPath(),
"utf-8");
RelationalInputGenerator
inputGenerator =
new DefaultFileInputGenerator(new File(pathToInputFile));
return inputGenerator;
}
示例9: matches
import java.net.URLDecoder; //导入方法依赖的package包/类
@Override
public boolean matches(final Service service) {
try {
final String thisUrl = URLDecoder.decode(this.id, "UTF-8");
final String serviceUrl = URLDecoder.decode(service.getId(), "UTF-8");
logger.trace("Decoded urls and comparing [{}] with [{}]", thisUrl, serviceUrl);
return thisUrl.equalsIgnoreCase(serviceUrl);
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
return false;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:AbstractWebApplicationService.java
示例10: determinePSPParams
import java.net.URLDecoder; //导入方法依赖的package包/类
/**
* Converts the input given in the request to a properties object.
*
* @param request
* The received request.
* @return The properties contained in the request.
* @throws IOException
* Thrown in case the request information could not be
* evaluated.
*/
private boolean determinePSPParams(HttpServletRequest request, Properties p) {
try {
ServletInputStream inputStream = request.getInputStream();
if (inputStream == null) {
return false;
}
BufferedReader br = new BufferedReader(new InputStreamReader(
inputStream, "UTF-8"));
String line = br.readLine();
StringBuffer sb = new StringBuffer();
while (line != null) {
sb.append(line);
line = br.readLine();
}
String params = sb.toString();
StringTokenizer st = new StringTokenizer(params, "&");
while (st.hasMoreTokens()) {
String nextToken = st.nextToken();
String[] splitResult = nextToken.split("=");
String key = splitResult[0];
String value = "";
if (splitResult.length > 1) {
value = URLDecoder.decode(splitResult[1], "UTF-8");
}
p.setProperty(key, value);
}
return validateResponse(p);
} catch (IOException e) {
// if the request information cannot be read, we cannot determine
// whether the registration worked or not. Hence we assume it
// failed, log a warning and return the failure-URL to the PSP.
logger.logWarn(Log4jLogger.SYSTEM_LOG, e,
LogMessageIdentifier.WARN_HEIDELPAY_INPUT_PROCESS_FAILED);
}
return false;
}
示例11: getDecodedCidPart
import java.net.URLDecoder; //导入方法依赖的package包/类
private MIMEPart getDecodedCidPart(String cid) {
MIMEPart part = partsMap.get(cid);
if (part == null) {
if (cid.indexOf('%') != -1) {
try {
String tempCid = URLDecoder.decode(cid, "utf-8");
part = partsMap.get(tempCid);
} catch (UnsupportedEncodingException ue) {
// Ignore it
}
}
}
return part;
}
示例12: decodeURIComponent
import java.net.URLDecoder; //导入方法依赖的package包/类
/**
* Decode the uri string.
* @param uri
* the uri string
* @return the decoded uri
*/
public static String decodeURIComponent(String uri) {
try {
return URLDecoder.decode(uri, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
return uri;
}
}
示例13: QParams
import java.net.URLDecoder; //导入方法依赖的package包/类
QParams(String q) throws UnsupportedEncodingException {
for (String p: QueryEncoderBackend.decode(q).split("&")) {
String name = p.substring(0, p.indexOf('='));
String value = URLDecoder.decode(p.substring(p.indexOf('=') + 1), "UTF-8");
List<String> values = iParams.get(name);
if (values == null) {
values = new ArrayList<String>();
iParams.put(name, values);
}
values.add(value);
}
}
示例14: getClassPath
import java.net.URLDecoder; //导入方法依赖的package包/类
/**
* 获得类文件
* @param clazz
* @return File
*/
public static File getClassPath(Class<?> clazz) {
String className=clazz.getSimpleName()+".class";
String path =clazz.getResource(className).getPath();
try {
path=URLDecoder.decode(path,ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
File file = new File(path);
return file;
}
示例15: urlDecode
import java.net.URLDecoder; //导入方法依赖的package包/类
private static String urlDecode(String string) {
if (string == null || string.length() == 0) {
return string;
}
try {
return URLDecoder.decode(string, "UTF-8");
}
catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}