本文整理汇总了Java中com.sun.jndi.toolkit.url.UrlUtil.encode方法的典型用法代码示例。如果您正苦于以下问题:Java UrlUtil.encode方法的具体用法?Java UrlUtil.encode怎么用?Java UrlUtil.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jndi.toolkit.url.UrlUtil
的用法示例。
在下文中一共展示了UrlUtil.encode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toUrlString
import com.sun.jndi.toolkit.url.UrlUtil; //导入方法依赖的package包/类
static String toUrlString(String host, int port, String dn, boolean useSsl)
{
try {
String h = (host != null) ? host : "";
if ((h.indexOf(':') != -1) && (h.charAt(0) != '[')) {
h = "[" + h + "]"; // IPv6 literal
}
String p = (port != -1) ? (":" + port) : "";
String d = (dn != null) ? ("/" + UrlUtil.encode(dn, "UTF8")) : "";
return useSsl ? "ldaps://" + h + p + d : "ldap://" + h + p + d;
} catch (UnsupportedEncodingException e) {
// UTF8 should always be supported
throw new IllegalStateException("UTF-8 encoding unavailable");
}
}
示例2: constructProviderUrl
import com.sun.jndi.toolkit.url.UrlUtil; //导入方法依赖的package包/类
private static String constructProviderUrl(String domain,
String[] servers) {
String path = "";
if (!domain.equals(".")) {
try {
path = "/" + UrlUtil.encode(domain, "ISO-8859-1");
} catch (java.io.UnsupportedEncodingException e) {
// assert false : "ISO-Latin-1 charset unavailable";
}
}
StringBuffer buf = new StringBuffer();
for (int i = 0; i < servers.length; i++) {
if (i > 0) {
buf.append(' ');
}
buf.append("dns://").append(servers[i]).append(path);
}
return buf.toString();
}
示例3: constructProviderUrl
import com.sun.jndi.toolkit.url.UrlUtil; //导入方法依赖的package包/类
private static String constructProviderUrl(String domain,
String[] servers) {
String path = "";
if (!domain.equals(".")) {
try {
path = "/" + UrlUtil.encode(domain, "ISO-8859-1");
} catch (java.io.UnsupportedEncodingException e) {
// assert false : "ISO-Latin-1 charset unavailable";
}
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < servers.length; i++) {
if (i > 0) {
sb.append(' ');
}
sb.append("dns://").append(servers[i]).append(path);
}
return sb.toString();
}
示例4: convertUriSchemeForProxyQuery
import com.sun.jndi.toolkit.url.UrlUtil; //导入方法依赖的package包/类
public static String convertUriSchemeForProxyQuery(URI uri) throws URISyntaxException, UnsupportedEncodingException {
// there is no easy way to get SOCKS proxy info. So, we tell mozilla that we want proxy for
// an HTTP uri in case of non http/ftp protocols. If we get back a SOCKS proxy, we can
// use that, if we get back an http proxy, we fallback to DIRECT connect
String scheme = uri.getScheme();
if (!scheme.startsWith("http") && !scheme.equals("ftp")) {
scheme = "http";
}
URI result = new URI(scheme, uri.getUserInfo(), uri.getHost(), uri.getPort(),
uri.getPath(), uri.getQuery(), uri.getFragment());
return UrlUtil.encode(result.toString(), "UTF-8");
}