title: Parse Binary Data
body: <p>I have an application that receives data in binary form through Bluetooth. I read the data using inputstream from a bluetoothsocket to a byte[]. But I must parse all messages, because they must have a given format to be valid. All messages are in binary.</p>
  <p>My solution was to convert the byte[] to a string and then split the string and parse all received messages.</p>
  <p>An example of the data to parse:
  0000000010000001</p>
  <p>I should know that the first 8 zeros are the header and 10000001 the real data.</p>
  <p>My idea was to create a string (from the byte[]) that represents -&gt; 0000000010000001
  using new String(byte[])
  and then split the whole string in one byte and check the value, like:</p>
  <p>string1 had 00000000
  string2 had 10000001</p>
  <p>I know that 8 zeros are the header, therefore string2 has the representation of the data.</p>
  <p>My question is about the efficiency of this method. Is this the best method to do this in a mobile environment?</p>