Ugu*_*men 5

为了修改查询,你可以使用appendQueryParameter来表示像"|"这样的普通字符串,你可以使用encodedQuery来预编码字符串,如"%7C".

预编码的查询参数没有附加方法.


sta*_*ang 5

%7C已编码的字符,可能是中文代码或其他字符,因此如果您想在URL中添加一些参数,只需使用URLEncoder.encode对原始字符串进行编码.像这样:

Uri.Builder builder = new Uri.Builder();
builder.scheme("http")
.authority("www.lapi.transitchicago.com")
.appendPath("api")
.appendPath("1.0")
.appendPath("ttarrivals.aspx")
.appendQueryParameter("key", "[redacted]")
.appendQueryParameter("mapid",URLEncoder.encode("&&&","UTF-8"); //note this
Run Code Online (Sandbox Code Playgroud)