Thursday, 15 July 2010

java - How can I treat an underlying byte array as an array of shorts? Or ints? Or longs? -


I am an embedded engineer, working in Java I need to communicate with the equipment, Buffers are required by hardware or by means of form to massage the buffers.

I spent a lot of time searching for an answer for Net (and this site) how many behaviors of the byte buffer as a buffer of large elements, but they are always (1) byte buffer Or (2) do manually conversion.

The problem is, there is no conversion required ... the underlying byte array is valid shorts, along with the correct endurance I do not want the value of copying an array of bytes in the same array of shorts. What I want to do is to convince the Java compiler in such a way that how interested I am.

I do not have much experience with a bitfuffer, but this was the first way down. I have come to know that if I have a bytebuffer and I call it as a shortbuffer () function, then there is no backing array of the shortbuff as a result ... I can not say array on it, which I What do you need.

Any thoughts?

Do you really need a shortbuff? Why not use different receiving / piping methods on the bytebuff to read / write the original byte array not just at least, from int and other values?

No comments:

Post a Comment