资源简介

HttpClient实现POST GET和文件下载

资源截图

代码片段和文件信息

import java.util.HashMap;
import java.util.Map;

import net.mobctrl.HttpClientUtils;
import net.mobctrl.HttpClientUtils.HttpClientDownLoadProgress;

/**
 * @date 2015年1月14日 下午1:49:50
 * @author Zheng Haibo
 * @Description: 测试
 */
public class Main {

public static void main(String[] args) {
/**
 * 测试下载文件 异步下载
 */
HttpClientUtils.getInstance().download(
“http://newbbs.qiniudn.com/phone.png“ “test.png“
new HttpClientDownLoadProgress() {

@Override
public void onProgress(int progress) {
System.out.println(“download progress = “ + progress);
}
});

// POST 同步方法
Map params = new HashMap();
params.put(“username“ “admin“);
params.put(“password“ “admin“);
HttpClientUtils.getInstance().httpPost(
“http://localhost:8080/sshmysql/register“ params);

// GET 同步方法
HttpClientUtils.getInstance().httpGet(
“http://wthrcdn.etouch.cn/weather_mini?city=北京“);

}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-01-14 23:17  HttpClientTest\
     文件         743  2015-01-14 11:17  HttpClientTest\.classpath
     文件        6148  2015-01-14 23:17  HttpClientTest\.DS_Store
     目录           0  2015-01-14 23:17  __MACOSX\
     目录           0  2015-01-14 23:17  __MACOSX\HttpClientTest\
     文件         120  2015-01-14 23:17  __MACOSX\HttpClientTest\._.DS_Store
     文件         373  2015-01-14 11:15  HttpClientTest\.project
     目录           0  2015-01-14 11:15  HttpClientTest\.settings\
     文件         587  2015-01-14 11:15  HttpClientTest\.settings\org.eclipse.jdt.core.prefs
     目录           0  2015-01-14 23:13  HttpClientTest\bin\
     文件         901  2015-01-14 23:13  HttpClientTest\bin\Main$1.class
     文件        1418  2015-01-14 23:13  HttpClientTest\bin\Main.class
     目录           0  2015-01-14 22:54  HttpClientTest\bin\net\
     目录           0  2015-01-14 23:08  HttpClientTest\bin\net\mobctrl\
     文件        1049  2015-01-14 23:14  HttpClientTest\bin\net\mobctrl\HttpClientUtils$1.class
     文件        1262  2015-01-14 23:14  HttpClientTest\bin\net\mobctrl\HttpClientUtils$2.class
     文件         271  2015-01-14 23:14  HttpClientTest\bin\net\mobctrl\HttpClientUtils$HttpClientDownLoadProgress.class
     文件        9932  2015-01-14 23:14  HttpClientTest\bin\net\mobctrl\HttpClientUtils.class
     目录           0  2015-01-14 11:17  HttpClientTest\bin\org\
     目录           0  2015-01-14 11:17  HttpClientTest\bin\org\apache\
     目录           0  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\
     目录           0  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\client\
     目录           0  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\client\fluent\
     文件        1847  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\client\fluent\FluentAsync$1.class
     文件        2694  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\client\fluent\FluentAsync.class
     文件        3110  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\client\fluent\FluentExecutor.class
     文件        1308  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\client\fluent\FluentQuickStart.class
     文件        2564  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\client\fluent\FluentRequests.class
     文件        3431  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\client\fluent\FluentResponseHandling$1.class
     文件        1208  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\client\fluent\FluentResponseHandling.class
     目录           0  2015-01-14 11:17  HttpClientTest\bin\org\apache\http\examples\
............此处省略80个文件信息

评论

共有 条评论