Get actual size of a gzip file in android <p>I am using GZIPInputStream to download pdf file I want to show the download progress of the file on a UI button. But, I am not getting the actual size of the file , what I am getting is compressed size due to which I am unable to show the correct download progress. This download progress is exceeding 100 as the actual file size is greater than the compressed size of file. Header content of file from server : - Following info I receive from server, from which I am using content-length which is giving compressed file size.</p> <p>1.Connection 2.Content-Encoding 3.Content-length 4.Content-Type 5.Keep-Alive 6.Server 7.Date</p> <p>Here is my code.</p> <pre><code> long fileLength = httpResponse.getEntity().getContentLength();// GZIPInputStream input = new GZIPInputStream(new BufferedInputStream(httpResponse.getEntity().getContent())); FileOutputStream output = new FileOutputStream(destinationFilePath); byte data[] = new byte[1024]; long total = 0; float percentage = 0; int count; currentDownloadingPercentage=0; while ((count = input.read(data)) != -1) { total += count; output.write(data, 0, count); // publishing the progress.... percentage = (float)total/(float)fileLength; percentage *= 100; if((int)percentage &gt; (int)currentDownloadingPercentage) { currentDownloadingPercentage = percentage; Bundle resultData = new Bundle(); resultData.putBoolean(DOWNLOAD_FAILED, false); resultData.putInt(DOWNLOAD_PROGRESS ,(int)percentage); receiver.send(processID, resultData); resultData = null; } } </code></pre>