I have a huge file, trying to send a portion of this file with a header and trailer. (a header + a portion of this file + trailing data)
Obvious solution is SocketChannel.write() which includes multiple system calls. So, I'm open to suggestions.
One option would be FileChannel.transferTo() but it doesn't allow to append any data before or after, so it includes 3 system calls at least.
Is there any other effective way to do it in Java? Maybe similar to FreeBSD's sendFile implementation : https://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2