If i have to download a large file, say > 200 mb, from the servlet if i use fileinputsream to read and write to the servletoutputstream i get outofmemory error. how do i split this file into various chunks and write them to the stream?
does using
response.setContentType("application/octet-stream");
solve the problem?
although i tried
outputStream = new GZIPOutputStream(response.getOutputStream(), 10240);
it didnt solve the problem.
can this be solved using the multi-part response? how about the browser compatibility? i read somewhere long back that IE do not understand this response ?
i have few pdf files in the file server. This pdf may vary in sizes. i need to let the client download them though the servlet. i receive the file name from the request and read the file using FileInputStream. i write them to the ServletOutputStream.
during this operation i receive OutOfMemoryError.
When someone on a Java forum asks about "how you're doing something" it's almost *always* a request for code, or at the *very* least, pseudo-code. Copying a file should use essentially zero memory unless you're doing it wrong. Read into a buffer, write the buffer out, repeat until done. No memory other than the buffer is being used.
Personally, I almost always just use something from commons-io, but it does the exact same thing.
So again, without knowing what you're doing, it's impossible to know what you might be doing wrong.