本文整理汇总了Java中org.apache.commons.httpclient.util.URIUtil.encode方法的典型用法代码示例。如果您正苦于以下问题:Java URIUtil.encode方法的具体用法?Java URIUtil.encode怎么用?Java URIUtil.encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.httpclient.util.URIUtil
的用法示例。
在下文中一共展示了URIUtil.encode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeAuthority
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public static String encodeAuthority(String uri) throws URIException
{
int start = uri.indexOf("//");
if(start == -1) return uri;
start++;
int end = uri.indexOf("/",start+1);
if(end == -1) end = uri.indexOf("?",start+1);
if(end == -1) end = uri.indexOf("#",start+1);
if(end == -1) end = uri.length();
String before = uri.substring(0, start+1);
String authority= uri.substring(start+1,end);
String after = uri.substring(end);
authority = URIUtil.encode(authority, URI.allowed_authority);
return before+authority+after;
}
示例2: encodePath
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public static String encodePath(String uri) throws URIException
{
int doubleSlashIndex = uri.indexOf("//");
boolean hasAuthority = doubleSlashIndex >= 0;
int start = -1;
if(hasAuthority)
{
start = uri.indexOf("/",doubleSlashIndex+2);
}
else
{
start = uri.indexOf(":");
}
if(start == -1) return uri;
int end = uri.indexOf("?",start+1);
if(end == -1) end = uri.indexOf("#",start+1);
if(end == -1) end = uri.length();
String before = uri.substring(0, start+1);
String path= uri.substring(start+1,end);
String after = uri.substring(end);
path = URIUtil.encode(path, URI.allowed_abs_path);
return before+path+after;
}
示例3: encodeQuery
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public static String encodeQuery(String uri) throws URIException
{
int queryStart = uri.indexOf("?");
if(queryStart == -1) return uri;
int queryEnd = uri.indexOf("#");
if(queryEnd == -1) queryEnd = uri.length();
String beforeQuery = uri.substring(0, queryStart+1);
String query = uri.substring(queryStart+1,queryEnd);
String afterQuery = uri.substring(queryEnd);
query = URIUtil.encode(query, URI.allowed_query);
return beforeQuery+query+afterQuery;
}
示例4: encodeFragment
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public static String encodeFragment(String uri) throws URIException
{
int fragmentStart = uri.indexOf("#");
if(fragmentStart == -1) return uri;
String beforeFragment = uri.substring(0, fragmentStart+1);
String fragment = uri.substring(fragmentStart+1);
fragment = URIUtil.encode(fragment, URI.allowed_fragment);
return beforeFragment+fragment;
}