InputStream partial reading problem
807607Oct 24 2006 — edited Oct 24 2006Hi, I have to read a big file partially, in my function as a parameter i will have
InputStream - 'is'
byte[] buffer = new byte[1024];
long sentBytes = 0;
int bytesRead = is.read(buffer, 0, 1024);
while (bytesRead > 0) {
sentBytes += bytesRead;
bytesRead = is.read(buffer, 0, 1024);
counter++;
}
i'm reading more than i should- how to cope with that? its a problem with last part of stream i suppose..
bytesRead = is.read(buffer, 0, chunkSize);
but when i call buffer.length at the end, it prints lower value than 1024, so where is the problem?