As we all know java allows us to use byte array as a buffer for data. My case here is with J2me
The scenario here is that I have two buffers of equal size and I need to swap them as they get full one by one ..
In detail Two buffers buff1 and buff2
Reading data from Buff1 while writing other data to buff2
Then when buff2 gets full
They swap their position now reading from buff2 and writing to buff1
The above cycle goes on
So how do I detect when a buffer is full and is ready to be swapped?
so how do I detect when a buffer is full
The buffer itself is never full (or empty). It is just a fixed amount of reserved memory.
You need to keep track of the useful parts (i.e. those with meaningful data) yourself. Usually, this is just an integer that counts how much bytes were written into the buffer (starting from the beginning).
When that integer reaches the buffer length, your buffer is "full".