java2019. 9. 22. 15:36

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() );
	
	
}

출처 : 자바의 신

Posted by easy16