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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:19:18+00:00 2026-06-11T05:19:18+00:00

I am having problems of conversion through string->byte->byte[] What I have done so far:

  • 0

I am having problems of conversion through string->byte->byte[]

What I have done so far:

     double db = 1.00;
     double ab = db*100;
     int k = (int) ab;

     String aa = String.format("%06d", k);

     String first = aa.substring(0,2);``
     String second = aa.substring(2,4);
     String third = aa.substring(4,6);

     String ff = "0x"+first;
     String nn = "0x"+second;
     String yy = "0x"+third;

I want to write those bytes to an byte[]. What I mean is:

byte[] bytes = new byte[]{(byte) 0x02, (byte) 0x68, (byte) 0x14,
    (byte) 0x93, (byte) 0x01, ff,nn,yy};

in this order and casted with 0x’s. Any help is greatly appriciated.

Regards,
Ali

  • 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-11T05:19:20+00:00Added an answer on June 11, 2026 at 5:19 am

    You can use Byte.decode()

    Decodes a String into a Byte. Accepts decimal, hexadecimal, and octal numbers given by the following grammar:

    DecodableString:
        Signopt DecimalNumeral 
        Signopt 0x HexDigits 
        Signopt 0X HexDigits 
        Signopt # HexDigits 
        Signopt 0 OctalDigits
    

    Below code will print 10, 11 which is value of 0XA, 0XB

        byte[] temp = new byte[2];
        temp[0] = Byte.decode("0xA");
        temp[1] = Byte.decode("0xB");
        System.out.println(temp[0]);
        System.out.println(temp[1]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problems compiling the following snippet int temp; vector<int> origins; vector<string> originTokens
Im having problems with classpaths. I have used them before with import but I'm
I have been having problems with toBase64() for awhile. I am hoping someone can
I have a question regarding type conversion in C#. Object data_obj = test; string
I've been having problems lately with date conversion lately. Some workstations my application run
I'm having some problems with the conversion of value from an OracleDecimal. Here is
Having problems with a small awk script, Im trying to choose the newest of
Having problems iterating. Problem has to do with const correctness, I think. I assume
Having problems with the combining of two statements in a controller. Both statements work
Im having problems with displaying ONLY some elements ONLY on print page. For example

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.