cha1r

HttpClient怎么上传文件

2013-11-21 23:54  _cha1R  阅读(336)  评论(0编辑  收藏  举报

在使用HttpClient时,怎么上传文件到服务器?

很简单,只需要构建一个FileEntity

File file=new File("file.txt");
FileEntity entity=new FileEntity(file);
	
HttpPost httppost=new HttpPost("http://www.baidu.com/");
httppost.setEntity(entity);

然后提交这个Post即可:

httpClient.execute(httppost);

 

分类:

技术点:

相关文章:

  • 2021-08-30
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-10-02
  • 2021-11-17
猜你喜欢
  • 2021-10-27
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案