當前位置: 首頁>>代碼示例>>Java>>正文


Java URLDecoder.decode方法代碼示例

本文整理匯總了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;
	}
	*/
}
 
開發者ID:Betalord,項目名稱:BHBot,代碼行數:23,代碼來源:Misc.java

示例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;
	}
 
開發者ID:isapir,項目名稱:lucee-websocket,代碼行數:27,代碼來源:HandshakeHandler.java

示例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;
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:31,代碼來源:UriUtils.java

示例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;
}
 
開發者ID:imliujun,項目名稱:LJFramework,代碼行數:26,代碼來源:UrlUtil.java

示例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;
}
 
開發者ID:forcedotcom,項目名稱:scmt-server,代碼行數:37,代碼來源:Utils.java

示例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;
    }
}
 
開發者ID:SimonMarquis,項目名稱:Android-App-Linking,代碼行數:9,代碼來源:Referrer.java

示例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();
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:36,代碼來源:TestVoltCompiler.java

示例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;
}
 
開發者ID:HPI-Information-Systems,項目名稱:metanome-algorithms,代碼行數:13,代碼來源:AbaloneFixture.java

示例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;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:50,代碼來源:PSPResponse.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:MIMEMessage.java

示例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;
    }
}
 
開發者ID:Microsoft,項目名稱:java-debug,代碼行數:14,代碼來源:AdapterUtils.java

示例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);
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:13,代碼來源:CalendarServlet.java

示例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;
}
 
開發者ID:VonChange,項目名稱:headb,代碼行數:17,代碼來源:HFileUtils.java

示例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);
	}
}
 
開發者ID:Webtrekk,項目名稱:webtrekk-android-sdk,代碼行數:13,代碼來源:Core.java


注:本文中的java.net.URLDecoder.decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。