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 7863755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:35:01+00:00 2026-06-02T23:35:01+00:00

I sending a byte array over a REST service. It is being received as

  • 0

I sending a byte array over a REST service. It is being received as String. Here is an extract of it. with start and end tags.

[0,0,0,0,32,122,26,65,0,0,0,0,96,123,26,65,0,0,0,0,192,123,20,65,0,0,0,0,0,125,20,65,71,73,70,56,57,97,244,1,244,1,247,0,0,51,85,51,51,85,102,51,85,153,51,85,204,51,85,255,51,128,0,51,128,51,51,128,102,51,128,153,51,128,204,51,128,255,51,170,0,51,170,51,51,170,102,51,170,153,51,170,204,51,170,255,51,213,0,51,213,51,51,213,102,51,213,153,51,213,204,51,213,255,51,255,0,51,255,51,51,255,102,51,255,153,51,255,204,51]

Now before anyone suggests sending it as a base64 encoded String, that would require Blackberry to actually have a working Base64 decoder. But alas, it fails for files over 64k and Ive tried alsorts.

Anyway this is what ive tried:

        str = str.replace('[', ' ');
        str = str.replace(']', ' ');
        String[] tokens = split(str,",");
        byte[] decoded = new byte[tokens.length];
        for(int i = 0; i < tokens.length; i++)
        {           
            decoded[i] = (byte)Integer.parseInt(tokens[i]);             
        }

But it fails. Where split is like the JAVA implementation found here.

Logically it should work? but its not. This is for JavaME / Blackberry. No Java Answers please (unless they work on javaME).

  • 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-02T23:35:02+00:00Added an answer on June 2, 2026 at 11:35 pm

    Two problems one minor and one that is a pain.
    Minor:whitespaces (as mentioned by Nikita)
    Major:casting to bytes … since java only has unsigned byte, 128 and higher will become negative numbers when casting from int to byte.

        str = str.replace('[',' ');
        str = str.replace(']', ' ');
        String[] tokens = split(str,",");//String[] tokens = str.split(",");
        byte[] decoded = new byte[tokens.length];
        for (int i = 0; i < tokens.length; i++) {
            decoded[i] = (byte) (Integer.parseInt(tokens[i].trim()) & 0xFF);
        }
        for(byte b:decoded) {
            int tmp = ((int)b) & 0xff;
            System.out.print("byte:"+tmp);
        }
    

    (btw:implementing base64 encoder/decoder isn’t especially hard – might be “overkill” for your project though)

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

Sidebar

Related Questions

I'm reading a file into a byte array in chunks and sending it over
I'm sending a byte array to a piece of hardware. The first 7 bytes
I'm sending to a device a request as byte array and I want to
Newbie question: I'm sending a large text string in the form of a byte
I am sending byte arrays over a socket. The sent data starts off with
i am writing an application where i transfer a byte array over a socket
I have client-server app. Client on C++, server on Java. I am sending byte-stream
I have a problem when I want to sending data using byte format in
When sending TCP packets over a high latency network, one can set the TCP
I have a problem. I sent some data over a socket in string form.

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.