开发者

Downloading large files with HttpClient

Is it possible to download large files (>=1Gb) from a servlet to an applet using HttpClient? And what servlet-side lib is useful in this case? Is there an开发者_如何学Goother way to approach this?


Any server-side lib that allows you access to the raw output stream should be just fine. Servlets or JAX-RS for example. Get the output stream, get the input stream of your file, use a nice big buffer (4k maybe) and pump the bytes from input to output.

On the client side, your applet needs access to the file system. I assume you don't want to keep the 1GB in memory. (maybe we want to stream it to the screen, in which case you don't need elevated access).

Avoid client libraries that try to fully materialize the returned content before handing it to.

Example code here: Streaming large files in a java servlet

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜