flip means-> set limit to current position and set position to 0
ex)
private void intBufferTest(){ IntBuffer buffer = IntBuffer.allocate(1024); for ( int loop = 0 ; loop < 100 ; loop ++) { buffer.put(loop); } System.out.println("Buffer capacity : " + buffer.capacity() ); System.out.println("Buffer limit : " + buffer.limit() ); System.out.println("Buffer position : " + buffer.position() ); buffer.flip(); System.out.println("Buffer flipped! set limit to current position! and set position to " ); System.out.println("Buffer limit : " + buffer.limit() ); System.out.println("Buffer position : " + buffer.position() ); }
출처 : 자바의 신
'java' 카테고리의 다른 글
Simple UDP server & client socket 예제 (0) | 2019.09.22 |
---|---|
Simple server & client socket 예제 (0) | 2019.09.22 |
NioSample (0) | 2019.09.22 |
Serializable interface, transient 예약어, FileInputStream, FileOutputStream, ObjectInputStream, ObjectOutputStream 예제 (0) | 2019.09.22 |
FileReader 및 BufferedReader + (Scanner) (0) | 2019.09.22 |