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

  • SEARCH
  • Home
  • 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 8386171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:51:43+00:00 2026-06-09T17:51:43+00:00

in my program I receive a bytearray. The first part is actually a string

  • 0

in my program I receive a bytearray. The first part is actually a string and the second a picture converted into a byte array.
Like this:

<STX>1<US>length of picture<ETX> here are the bytes...  

At the moment I have this to split the part before and after the ETX

string incomingMessage = incomingBytes.toString();

String messagePart = incomingMessage.substring(0, firstETX);
String dataPart = incomingMessage.substring(firstETX, incomingMessage.length());

Afterwards I use

dataPart.getBytes();

To convert it back into a byte array.

But I think converting the bytes containing the image causes some problems, because my program won’t convert the bytes to an image.

So how do I get the bytes after the ETX without converting it to a string?
Or how do I keep the original bytes so I can use them?

Thx

  • 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-06-09T17:51:45+00:00Added an answer on June 9, 2026 at 5:51 pm

    You need to find the postion of <ETX> inside your byte array. You can then use that as an offset for BitmapFactory.decodeByteArray

    I wasn’t able to test this code but you should get the idea.

      final byte[] etxBytes = {'<','E','T','X','>'};
        int i =0 ;
        boolean found = false;
        for (i = 0; !found && (i < (incomingBytes.length-etxBytes.length)); i++){
            found = true;
            for (int j=i; (j-i) < etxBytes.length && found; j++){
                if (etxBytes[j-i]!=incomingBytes[j]){
                    found = false;
                    break;
                }
            }
        }
        if (found){
            int offset = i + etxBytes.length;
            Bitmap image = BitmapFactory.decodeByteArray(incomingBytes, offset, incomingBytes.length-offset);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my C# program i receive date & time like this: DateTime.Now and i
When trying to declare a static array in my program I receive a static
I'm trying to write a simple program that will receive a string of max
I would like to write a program to receive some data using tcpClient from
I'm learning Ruby and working on my first real project. The program will receive
When adding this code to a simple calculator program I receive the error message
Can anyone help in analysing this crash issue? The program did receive memory warning
I am trying to call a prolog program and receive output into my bash
I have a C program that receives a 64 byte array of char (which
The program under discussion attempts to compute sum-of-first-n-natural-numbers using recursion . I know this

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.