java - difference between bytebuffer.flip() and bytebuffer.rewind() -
i aware flip() set current buffer position 0 , set limit previous buffer position whereas rewind() set current buffer position 0.
in following code, either use rewind() or flip() same result.
byte b = 127; bb.put(b); bb.rewind();//or flip(); system.out.println(bb.get()); bb.rewind();// or flip(); system.out.println(bb.get()); could provide me real example difference of these 2 methods matters? in advance. edit: found solution in this link, it's explained , detailed thorough understanding of buffer , channel classes' use.
they're not equivalent @ all.
a bytebuffer ready read() (or put()).
flip() makes ready write() (or get()).
rewind() , compact() , clear() make ready read()/put() again after write() (or get()).
Comments
Post a Comment