Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interpret stream data ---- URGENT

 
Roopa Joshi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a requirement in which i have to read the data sent by C prog as an array. The data is in structure format. How do i interpret the data.
Ex: The structure i send has int, float and bmp in it.
I will be receiving the stream on client side. How do i get the values.
i am using following code to read the int value from the first four bytes of the array.
(byte1&0x000000ff)|((byte2&0x000000ff)<<8)|((byte3&0x000000ff)<<16)|((byte4&0x000000ff)<<24)
Is this the only approach. Or is there any other better way of doing it ?
Pls help me soon...itz very urgent
Thanks in advance
 
Paul Frey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what you are looking for is available in Java 1.4's NIO api:
ScatteringByteChannel
You can read more about the NIO package at High-Performance I/O Arrives
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic