Thanks for your reply! I changed the code and did the usual AndroidStudio restart/clean/build but most images are still downloaded incompletely. I don't know if my other answer (sent about an hour ago) came through (I did some more testing today), so here's an imgur album with test images and their results: https://imgur.com/a/Mzngp11
The last image (the satellite one) was now also affected for the first time. -----Ursprüngliche Nachricht----- Von: Robert Paasche <[email protected]> Gesendet: Donnerstag, 4. Juni 2020 12:18 An: Commons Users List <[email protected]> Betreff: Re: [net] FTPClient doesn't download full images The following line is wrong: while ((len = bis.read(buf)) > 0) { //Same result using only 'is' read == -1 marks the end of the stream. 0 shows only that the stream is still waiting for the next chunk of data. Please read the JavaDocs: > Returns: > the number of bytes read, or -1 if the end of the stream has been reached. while ((len = bis.read(buf)) >= 0) { //Same result using only 'is' if (len >0) out.write(buf, 0, len); else // prevent high CPU load LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(500)); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
