У меня есть сервлет, который загружает файлы запрошенному клиенту. Теперь, когда пользователь запрашивает загрузку xml-файла. Он начнет загрузку, и когда он завершится, файл будет выглядеть неполным. В конце файла отсутствуют некоторые данные.
Мой код выглядит так:
File file = new File(location);
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=" + fileName);
FileInputStream fileIn = new FileInputStream(file);
OutputStream out = response.getOutputStream();
byte[] outputByte = new byte[4096];
int length = -1;
//copy binary contect to output stream
while((length = fileIn.read(outputByte)) > 0)
{
out.write(outputByte);
}
fileIn.close();
out.flush();
out.close();
Где мой код не может загрузить полный XML-файл?