Hi Everyone,

Im encountering the following problem. I need to read a powerpoint
file located on a server from my client machine.
When I run the program, all the bytes are not copied correctly.
Buy when I run in debug mode, all the bytes are copied CORRECTLY.
This problem occurs for file sizes > 10kb.
The reason I see is that the debugger gives some delay in the
processing, which in turn enables the bytes to be read correctly.
Im not sure if there is some issue with buffer.

My code is:

Document document = documentService.retrieveDocument(docId);
System.out.println("Document returned:\n" + document);
helper.setContentType(document.getMimeType());
helper.setHeader("Content-Disposition", "attachment;
filename=\"" + document.getFileName() + "\"");

OutputStream out = helper.getBinaryStream();
int len = document.getFileStream().length;
System.out.println(len);

byte[] stream2 = document.getFileStream();

for(int i = 0; i < stream2.length; i++){
System.out.print(stream2[i]);
}
out.write(document.getFileStream());
out.flush();
out.close();

and the method retrieveDocument(docId) is show below:
private byte[] requestDocument(URL url) throws
DocumentAccessException {
try {
HttpURLConnection con = (HttpURLConnection)
url.openConnection();
InputStream in = con.getInputStream();
byte[] stream = new byte[con.getContentLength()];

System.out.println("Stream length is :"+stream.length);
for (int i=0;i<stream.length;i++){
in.read(stream);
}

for(int i=0;i<stream.length;i++){
System.out.println(stream[i]);
}

return stream;

} catch (Exception e) {
Logger.log(new LoggableError(e));
throw new DocumentAccessException("Unable to retrieve
document at location: '" + url.getPath() + "'");
}
}

If someone can figure this out (worked with streams & readin files
over the network), PLZZZZZZZ....let me knw ASAP.