Relates :
|
In this test there is a loop long pos = 0L; for (;;) { bb.clear(); int n = fc.read(bb, pos); if (n > 0) pos += n; // fc.size is important here as it is position sensitive if (pos > fc.size()) // incorrect relational operator: should be >= pos = 0L; } which is supposed to read continuously from a FileChannel. This will not happen however because the value of pos will reach fc.size() which is 1024*1024 + 1 and remain there for all subsequent iterations of the loop in which case fc.read() would no longer read any bytes. The relational operator ">" should be changed to ">=".