Welcome to the Ranch, Aroz. People here can be very helpful, but no one here will do it all for you. Best way is for you to post what you've tried to do in Java already, and let us point out problems and suggest possible solutions.
When you do, useCodeTags <- click on this. They make it much easier to read and discuss your code.
"Il y a peu de choses qui me soient impossibles..."
I added the code tags for you this time. People will be more willing to help you if you add code tags.
The biggest problem I can see is writing or emulating the Buffer class. Are you sure you want to do this? Why does the code need to be rewritten in Java? Can you tell us a little more background information?
All things are lawful, but not all things are profitable.