I do not know why the result is different from systems, although the code is erroneous, and I suspect that it has something to do with the observed behavior.
while (0 <= in.read(bytes, 0, 1024)) { out.write(bytes); }
Must be:
int count; while ((count = in.read(bytes, 0, 1024)) > 0) { out.write(bytes, 0, count); }
Otherwise, there is a [high] chance that βgarbageβ is written at the end, which may explain the blur, depending on the program that is trying to view the [damaged] image file. (The size of the array used as a buffer does not change - it should record only as much data as was written on it.)
Happy coding.
user166390
source share