Guest User

Untitled

a guest
Oct 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. private double timeStamp;
  2. private float duration;
  3. private short scoreBits;
  4.  
  5. byte[] bytes = new byte[14];
  6.  
  7. int k=1;
  8. double n=0.0;
  9. for(int i=0;i<8;i++){
  10. n=n*k+b[i];
  11. k*=10;
  12. }
  13.  
  14. ByteBuffer.wrap(Arrays.copyOfRange(bytes , 0, 7)).getDouble();
  15. ByteBuffer.wrap(Arrays.copyOfRange(bytes , 8, 12)).getFloat();
  16. ByteBuffer.wrap(Arrays.copyOfRange(bytes , 13, 14)).getShort();
  17.  
  18. ByteBuffer bb = ByteBuffer.wrap(bytes);
  19. bb.putDouble(timeStamp);
  20. bb.putFloat(duration);
  21. bb.putShort(scoreBits);
  22.  
  23. ByteArrayOutputStream baos = new ByteArrayOutputStream(14);
  24. DataOutputStream dos = new DataOutputStream(baos);
  25. dos.writeDouble(timeStamp);
  26. dos.writeFloat(duration);
  27. dos.writeShort(scoreBits);
  28. bytes = baos.toByteArray();
Add Comment
Please, Sign In to add comment