Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private double timeStamp;
- private float duration;
- private short scoreBits;
- byte[] bytes = new byte[14];
- int k=1;
- double n=0.0;
- for(int i=0;i<8;i++){
- n=n*k+b[i];
- k*=10;
- }
- ByteBuffer.wrap(Arrays.copyOfRange(bytes , 0, 7)).getDouble();
- ByteBuffer.wrap(Arrays.copyOfRange(bytes , 8, 12)).getFloat();
- ByteBuffer.wrap(Arrays.copyOfRange(bytes , 13, 14)).getShort();
- ByteBuffer bb = ByteBuffer.wrap(bytes);
- bb.putDouble(timeStamp);
- bb.putFloat(duration);
- bb.putShort(scoreBits);
- ByteArrayOutputStream baos = new ByteArrayOutputStream(14);
- DataOutputStream dos = new DataOutputStream(baos);
- dos.writeDouble(timeStamp);
- dos.writeFloat(duration);
- dos.writeShort(scoreBits);
- bytes = baos.toByteArray();
Add Comment
Please, Sign In to add comment