We have the below requirement.
We will have to create an excel/pdf report and then download it on click of a button in a java web application. The pdf/excel file is dynamically created using application data.
We should not create any physical file on the server.
How do we go about this? Are there any streams through which I can read and write in the same go without having to close in between.
You could use memory-based streams (such as
ByteArrayInputStreamandByteArrayOutputStream) and use the same underlying byte buffer to address the read/write in the same go part of the question.As others have pointed out, you can just write directly to the output stream of the response.