System.out.println(" @ bBuffer = " + bBuffer.capacity());
headerBuffer.rewind();
socketChannel.write(headerBuffer);
int writen = socketChannel.write(bBuffer);
System.out.println(" @ writen = " + writen);
bBuffer
is an object of type ByteBuffer
and it came from FileChannel.map()
(it's an image file). When I receive this image file on client, it wasn't a complete image--about half of image was missing. So I checked how much bytes was written by printing some statistics to the console. The output was:
@ bBuffer = 319932
@ writen = 131071
What happened to the rest of the bytes? It seems that (319923 - 131071) bytes are missing.
Sometimes written
is equals to bBuffer.capacity()
and it's seems irrespective to file size or buffer capacity.