计算InputStream的size

int read = -1;
        int size = 0;
while((read=inputstream.read(buffer))!=-1)
        {
            if(read>0)
            {
                byte[] chunk = new byte[read];
                System.arraycopy(buffer,0,chunk,0,read);
                chunks.add(chunk);
                size += chunk.length;
            }
        } 

你可能感兴趣的:(计算InputStream的size)