Usually, flip() is called before buffer data is read. the rewind() method does bellowing works:
public final Buffer rewind() {
position = 0;
mark = -1;
return this;
}
it does not set the 'limit' as flip() does:
public final Buffer flip() {
limit = position;
position = 0;
mark = -1;
return this;
}
So, take a tray using flip() instead of rewind() before reading.