Depending on how large the files are, this may not be a good idea. If the files are megabytes in size, for example, then this will take up a lot of memory and may negatively impact the overall performance of your web application. But if you don't think that this will be a problem,
you should be able to accomplish this by passing a ByteArrayOutputStream into the constructor of the output stream object.