andr o id开发 http工具类public static HttpClient httpClient=new DefaultHttpClient();public static final String BASE_URL=
*get请求
*@param url
*发送请求的URL
*@r eturn服务器响应字符串
*@throw s Exc eptionpublic static String doGet(String url) throws Exc eption{//创建Http Get对象。
HttpGet get=new HttpGet(url);
//发送GET请求
HttpRes pons e httpRes pons e=httpClient.exec ute(get);//如果服务器成功地返回响应if(httpRespons e.getStatus Line().getStatus Code()==200) {//获取服务器响应字符串
HttpEnt ity entity=httpRe s p ons e.getEntity();
InputS tream c ontent=entity.getContent();return c onvertStreamTo String(c ontent);r eturn null;
*p os t请求
*@param url
*发送请求的URL
*@param params
*请求参数
*@r eturn服务器响应字符串
*@throw s Exc eptionpublic static String doPost(String url,Map String,String rawParams)throw s Exc eption{
//创建Http P o st对象。
HttpPost post=new HttpPost(url);
//如果传递参数个数比较多的话可以对传递的参数进行封装List NameValuePair params=new ArrayList NameValuePairfor(String key:rawParams.keySet()) {
//封装请求参数params.add(new BasicNameValuePair(key, rawParams.get(key)));//设置请求参数post.s etEntity(new UrlEnc odedFormEntity(params,utf-8));//发送P O ST请求
HttpRes pons e httpRes pons e=http Client.exec ute(po s t);
//如果服务器成功地返回响应if(httpRespons e.getStatus Line().getStatus Code()==200) {
//获取服务器响应字符串
HttpEnt ity entity=httpRe s p ons e.getEntity();
InputS tream c ontent=entity.getContent();
return c onvertStreamToString(c ontent);r eturn null;
*获取服务器的响应转换为字符串private static String convertStreamToString(InputStream is) {
BufferedReader reader=new BufferedReader(new InputStreamReader(is));StringBuilder sb=new StringBuilder();
String line=null;try{w hile((line=reader.readL ine()) !=null) {sb.append(line);
} catch(IOException e) {e.printStackTrac e();
}final ly{try{is.c lo s e();
} catch(IOException e) {e.printStackTrac e();return sb.toString();
HostKvm,我们很多人都算是比较熟悉的国人服务商,旗下也有多个品牌,差异化多占位策略营销的,商家是一个创建于2013年的品牌,有提供中国香港、美国、日本、新加坡区域虚拟化服务器业务,所有业务均对中国大陆地区线路优化,已经如果做海外线路的话,竞争力不够。今天有看到HostKvm夏季优惠发布,主要针对香港国际和韩国VPS提供7折优惠,折后最低月付5.95美元,其他机房VPS依然是全场8折。第一、夏...
SugarHosts 糖果主机商我们算是比较熟悉的,早年学会建站的时候开始就用的糖果虚拟主机,目前他们家还算是为数不多提供虚拟主机的商家,有提供香港、美国、德国等虚拟主机机房。香港机房CN2速度比较快,美国机房有提供优化线路和普通线路适合外贸业务。德国欧洲机房适合欧洲业务的虚拟主机。糖果主机商一般是不会发布黑五活动的,他们在圣圣诞节促销活动是有的,我们看到糖果主机商发布的圣诞节促销虚拟主机低至6折...
Dataideas是一家2019年成立的国外VPS主机商,提供基于KVM架构的VPS主机,数据中心在美国得克萨斯州休斯敦,主机分为三个系列:AMD Ryzen系列、Intel Xeon系列、大硬盘系列,同时每个系列又分为共享CPU和独立CPU系列,最低每月1.5美元起。不过需要注意,这家没有主页,你直接访问根域名是空白页的,还好他们的所有套餐支持月付,相对风险较低。下面以Intel Xeon系列共...