int count = 0;
byte[] buffer = new byte[8192]; // more if you like but no need for
int j = length_img % 8192;
int value = length_img - j;
int incre = 0;// it to be the entire file size
for (int i = 0; i < (value / 8192) + 1; i++) {
if (length_img == incre + j) {
buffer = new byte[j];
int pair = dataInputStream.read(buffer);
System.out.print("i am here for last chunk" + buffer.length
+ "value of j is" + j + "incre value is" + incre
+ "the value of i is" + i
+ "and the value of count is" + pair);
image0OutFile.write(buffer, 0, pair);
break;
}
else {
count = dataInputStream.read(buffer);
image0OutFile.write(buffer, 0, count);
incre += 8192;
}
}
これはいくつかの問題がある部分です。私はこの出力を取得しています length_img : 3147850 [B@72d86c58 i は最後のチャンクのためにここにいますj の値は 2122incre の値は 3145728i の値は 384 で、count の値は 496bublo ... の値に気付いた場合ペアは 2122 である必要がありますが、代わりに 496 であるため、ファイルが破損しています。