FileChannel.transferTo( Channel ) - this method can corrupt your data in 1.4.2, probably in 1.5.x too (can’t find any fixed bugs on this subject).
I just found a condition that’s causing Opera to get very upset which, when traced deep down, involves a file that is being sent using FileChannel.transferTo and dropping 2 bytes, consistently, in the same place. Suspiciously, this is precisely after sending the first 16 bytes.
Eventually, I got it narrowed down to the fact that NIO is reporting “96 bytes transferred” which happens to be the length of the source file (correct) but it is in fact only sending 94 of those bytes to the channel. This is an atomic operation (just one method in NIO) and it’s failing: I’m 99% sure this is nothing to do with my code - I don’t even think it’s possible to write code that takes stuff out of a channel that has already been put in. It’s very difficult to produce a “small” testcase because it only happens in NIO file-to-network, and you need 500 lines of code or so to get a full NIO network system running to demo with.
NB: the file in question is precisely 96 bytes in length; i.e. 2^6 + 2^5, which leads me to speculate this is a bug dependent upon a precise file length.