Note that there are some explanatory texts on larger screens.

plurals
  1. POHttp java file download problem
    primarykey
    data
    text
    <p>Trying to download file with apache httpclient library and have a problem with resulting file being smaller than the original (approximately 32-32kb, when normal file size is 92-93) and cannot be opened normally in pdf viewer. Can someone explain me why this can be happening ? (Using firefox to download this file can sometimes lead to file being downloaded fully and sometimes being downloaded partly) </p> <p>Here is code I was using to download file via URL</p> <pre><code> URL url = new URL("pathtofile"); final URLConnection connection = url.openConnection(); final InputStream is = connection.getInputStream(); FileOutputStream fos = new FileOutputStream("C://result1.pdf"); byte buffer[] = new byte[1024]; int bytesRead; while ((bytesRead = is.read(buffer)) &gt;= 0) { fos.write(buffer, 0, bytesRead); } fos.flush(); fos.close(); is.close(); </code></pre> <p>P.S. Was trying to download this file using HttpClient apache library, same result.</p> <p>UPDATED: Monitoring traffic with network tool I found the difference between receiving file via Firefox and application. </p> <p>With Firefox first HttpPayloadLine was :</p> <p><code>HTTPPayloadLine: 83 Td /F2 5.80476 Tf (A:\040Asinis\04017.12.10\04008:32\040laboratorij) Tj 100 Tz 1 1 1 rg /F1 5.80476 Tf 0 0 0 rg 104.4856 0 Td &lt;0145&gt; Tj 1 1 1 rg 0 0 0 rg 3.62799 0.72565 Td /F2 5.80476 Tf (\040) Tj 1 1 1 rg 0.83137 0.81569 0.78431 RG ET 51</code></p> <p>With application first HttpPayload was </p> <p><code>HTTPPayloadLine: CWgC,ú&amp;ÿ3@Î"ݯV¨®~×&gt;×)\ªleÚl</code>µï½ci ¤Ãðð'È/CÈAø¯ª Í<code>übA«1Ãÿ Åç«VɬZòYóóy7»ÇH.o²e&lt;qZna3l±°¥þ6ñþ[2YÚ1ì³Eë-ÓÊÏ$y:tÎà![ËÅS¤¿É¡¢è,þ|ºs¨)@¢Qâ¯ÝF~}oµÒ&gt;¦ OAxz³äÒ.ß9 æÃZ¤ùÒ¨*«øUή+4×</code></p> <p>This measurements was taken via Microsoft Network Monitor</p> <p><strong>LAST UPDATE</strong> It was a server problem after all, after they fixed that files are downloaded successful</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload