How to clear a buffer using clear method?
The code below show you how to clear a buffer using the
clear() method call. The clear method call set the
position in the buffer to
limit to the capacity of the buffer.
We usually call the
clear() method after we read the entire content of a buffer and clear it for ready to be written again. The
clear() method is actually not clearing the data in the buffer. It only clear the marker where you can write the data in the buffer and the unread data will be forgotten.