read() may also return 0 or -1. -1 for end of file. Also the implementation of read is done that subsequent reads also return -1. Also make sure your posting byte calculation is correct.

Problem code:
>         int bytesRead = inStream.read(inData);
>         fileOutStream.write(inData, 0, bytesRead);
>         totalBytesRead += bytesRead;

Alternative:
...
int contentLength = request.getContentLength();

InputStream inStream = request.getInputStream();
FileOutputStream fileOutStream = new FileOutputStream("SomePhoto.jpg");

byte[] inData = new byte[100];
int totalBytesRead = 0;
int bytesRead = inStream.read(inData);

while(bytesRead>=0 && totalBytesRead<contentLength) {
    fileOutStream.write(inData, 0, bytesRead);
    totalBytesRead += bytesRead;
    bytesRead = inStream.read(inData);
}

if (totalBytesRead<contentLength) {
    log("I didn't get enough data!");
}

inStream.close();
fileOutStream.close();

...



History detail of original message can be found at:
http://marc.theaimsgroup.com/?l=tomcat-user&m=105600834631106&w=2



-Tim


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to