我想使用的Jakarta Commons HttpClient库。

我想我是哑巴这里,但我无法弄清楚如何写一个完整的HttpEntity到文件。

我想:

FileOutputStream os = new FileOutputStream(f);

e.writeTo(os);
while (e.isStreaming()) {
   e.writeTo(os);
}

其中E是我的HttpEntity,f是我的文件。我只得到任何文件的第一个8KB,我想由于缓冲地方。任何想法,我怎么得到休息?

有帮助吗?

解决方案

解决它。

我需要强制响应对象使用BufferedHttpEntity:

HttpEntity entity = rsp.getEntity();
BufferedHttpEntity buf = new BufferedHttpEntity(entity);

其他提示

response = httpclient.execute(get);
is = response.getEntity().getContent();
IOUtils.copy(is,fileWriter);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top