Stephan van Hulst wrote:It pairs a piece of memory
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Stephan van Hulst wrote:
Another advantage is that ByteBuffer can be allocated directly in kernel space using allocateDirect(). When reading data from a file that way, you can read Java primitives directly from the block of memory that the disk controller writes to, instead of having that memory copied to user space first.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:I don't think a ByteBuffer is the tool if you just need to convert an object to byte[] (which is what BytesMessage needs) and back. BytesMessage already has the methods you need to write and read your String and primitive fields. For the enums, I'd write and read the name (using valueOf to convert back).
I've actually done the same in a project once - I just have conversion from ByteMessage to my classes and vice versa, that uses the read and write methods of BytesMessage itself.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Consider Paul's rocket mass heater. |