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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -