Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6606201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:22:14+00:00 2026-05-25T19:22:14+00:00

I have an application that receives data in binary form through Bluetooth. I read

  • 0

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.

My solution was to convert the byte[] to a string and then split the string and parse all received messages.

An example of the data to parse:
0000000010000001

I should know that the first 8 zeros are the header and 10000001 the real data.

My idea was to create a string (from the byte[]) that represents -> 0000000010000001
using new String(byte[])
and then split the whole string in one byte and check the value, like:

string1 had 00000000
string2 had 10000001

I know that 8 zeros are the header, therefore string2 has the representation of the data.

My question is about the efficiency of this method. Is this the best method to do this in a mobile environment?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:22:15+00:00Added an answer on May 25, 2026 at 7:22 pm

    String manipulation for parsing binary data is quite inefficient in terms of speed, memory consumption and also puts quite some burden on the garbage collector – because you always generate new string objects and forget them immediately.

    In Java you have several choices to do it better:

    • DataInputStream: is a wrapper for an InputStream where you read bytes, shorts, longs, doubles, etc directly from the stream.
    • NIO using ByteBuffers and “derived” types like ShortBuffer… these are good for bulkd data transfers and also for binary parsing.

    As long as your data is byte-aligned, these are easy ways to go. If that’s not the case – well, then better learn how to do bit-manipulation using operators like &, |, ~, <<, >>.

    My suggestion is that you stick to DataInputStream as long as possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Eclipse to develop an Android application that plots Bluetooth data. I
I have an application in java that uses two different threads.And for sharing data
I have a nice problem. I have an application that suspend the request and
I am making a QT application that updates the window based on the information
I am trying to receive data using serial communication in Python, which I can
I have an application in vb.net which will connect with an hardware device and
I have started to write a Python 3.x client application. The server application exists
We have several latency-sensitive pipeline-style programs that have a measurable performance degredation when run
One of my applications connect to a server module that is normally installed on
I get an error when I run my application which utilizes the OpenSL ES

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.