Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

long to byte array  RSS feed

 
Mohan Panigrahi
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to know how many bytes my long variable is occupying. For that I need to convert it into byte array. Is there any way to convert a long integer to byte array.
Actually I would also need to know how to convert float and char[] to byte array.
Thanks
Mohan
 
Mohan Panigrahi
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I got it.
I am using
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeLong(12l);
System.out.println(bos.toByteArray().length);
Thanks
Mohan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!