JavaはHttpClientを使用してストリームファイルをダウンロードします

HttpClientリクエスト後のコードの処理

HttpEntity entity = response.getEntity();
if (entity != null) {
    resp.reset();
    resp.setContentType("application/octet-stream;");
    InputStream is = entity.getContent();
    OutputStream out = resp.getOutputStream();
    byte[] bytes = new byte[1024];
    int len;
    while ((len = is.read(bytes)) != -1) {
         out.write(bytes, 0, len);
         out.flush();
       }
    is.close();
    out.close();
}

おすすめ

転載: blog.csdn.net/weirdo_world/article/details/128343501