Write file contents to OutputStream

Ugly code alert
OutputStream outputStream = response.getOutputStream();
    
FileInputStream fileInputStream = new FileInputStream(file);
            
// Copy the contents of the file to the output stream
byte[] buffer = new byte[1024];
int count = 0;
                
while ((count = fileInputStream.read(buffer)) >= 0) {
    outputStream.write(buffer, 0, count);
}                

outputStream.flush();
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.