The question is listed in the title. I transfer the file in parts to the pipe, it appears -> BufferOverflowException (I understand that this exception appears when the buffer overflows). It was also possible to completely transfer the file to 50 bytes (txt). Video, pictures do not pass. Exceptions appear in different ways, there is no exact limit of successfully transmitted bytes. The buffer reads by position, the position corresponds to the size of the buffer, nothing should overflow.
Addition:
Another small note. If before buffer.flip(); display positionRead -> System.out.println("positionRead " + positionRead); bytes will be written to the channel (Dynamically, as mentioned above with the appearance of an exception). But if the output line is removed - immediately without successfully transferred bytes, I get a BufferOverflowException . I do not know the reason, but perhaps this information will be useful.
For a better understanding of the picture made 4 screen.
Using System.out.println - https://ibb.co/geAL4S transmitted 30kb from 327kb. - https://ibb.co/h36yb7
Without using System.out.println - https://ibb.co/mwJ7jS, nothing was transmitted - https://ibb.co/mXON3n
ByteBuffer buffer = ByteBuffer.allocate(1024); fileChannel.read(buffer, positionRead); buffer.flip(); socketChannel.write(buffer);More info -> stackoverflow.com/questions/50112763/transfer-a-file - Akalit