I have the answer. You mustn't rely on InputStream.available() nor should you rely on InputStream.read(byte b) getting all the data all the time. It only gets the data that are "available" at that time. More data may become available after the read. It's asynchronous on some level. Better is to read from the InputStream in a loop until you find the end of the file, which is determined by InputStream.read(byte b) returning -1. This works for me:
ServletOutputStream oOutput = response.getOutputStream();
InputStream oDocInputStream = oDocument.getInputStream();
byte buffer = new byte[(int)oDocument.length()];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((bytesRead = oDocInputStreamread(buffer)) != -1)
baos.write(buffer, 0, bytesRead);
Hope this helps someone avoid the time loss that I experienced on this one.