Write file contents to OutputStream

Version 1 by Kees de Kooter
on Feb 12, 2007 09:18.

compared with
Current by Kees de Kooter
on Feb 12, 2007 09:34.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (3)

View Page History
{note:title=Ugly code alert}
{code}
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();
{code}