-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
217181c
commit 921e9b3
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cc.moecraft.utils; | ||
|
||
/** | ||
* 此类由 Hykilpikonna 在 2018/08/26 创建! | ||
* Created by Hykilpikonna on 2018/08/26! | ||
* Github: https://github.com/hykilpikonna | ||
* QQ: [email protected] -OR- 871674895 | ||
* | ||
* @author Hykilpikonna | ||
*/ | ||
public class URLBuilder | ||
{ | ||
private StringBuilder url; | ||
|
||
public URLBuilder(String baseUrl) | ||
{ | ||
url = new StringBuilder(baseUrl); | ||
} | ||
|
||
/** | ||
* 添加HTTP请求参数 | ||
* @param key 键 | ||
* @param value 值 | ||
*/ | ||
public URLBuilder addParameter(String key, String value) | ||
{ | ||
if (!url.toString().endsWith("&") || !url.toString().endsWith("?")) url.append("&"); | ||
url.append(key).append("=").append(value); | ||
return this; | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return url.toString(); | ||
} | ||
} |