4

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 another way to approach this?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
user592704
  • 3,674
  • 11
  • 70
  • 107

1 Answers1

0

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

Community
  • 1
  • 1
Jochen Bedersdorfer
  • 4,093
  • 24
  • 26