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();
今年1月的时候Hosteons开始提供1Gbps端口KVM架构VPS,目前商家在LET发布消息,到本月30日之前,用户下单洛杉矶/纽约/达拉斯三个地区机房KVM主机可以从1Gbps免费升级到10Gbps端口,最低年付仅21美元起。Hosteons是一家成立于2018年的国外VPS主机商,主要提供VPS、Hybrid Dedicated Servers及独立服务器租用等,提供IPv4+IPv6,支持...
imidc对日本独立服务器在搞特别促销,原价159美元的机器现在只需要88美元,而且给13个独立IPv4,30Mbps直连带宽,不限制流量。注意,本次促销只有一个链接,有2个不同的优惠码,你用不同的优惠码就对应着不同的配置,价格也不一样。88美元的机器,下单后默认不管就给512G SSD,要指定用HDD那就发工单,如果需要多加一个/28(13个)IPv4,每个月32美元...官方网站:https:...
CloudCone 商家产品还是比较有特点的,支持随时的删除机器按时间计费模式,类似什么熟悉的Vultr、Linode、DO等服务商,但是也有不足之处就在于机房太少。商家的活动也是经常有的,比如这次中国春节期间商家也是有提供活动,比如有限定指定时间段之前注册的用户可以享受年付优惠VPS主机,比如年付13.5美元。1、CloudCone新年礼物限定款仅限2019年注册优惠购买,活动开始时间:1月31...