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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:54:44+00:00 2026-05-26T23:54:44+00:00

I have a StringBuffer, strbuf=161656070200000000202020202001000000009E52; . I want to convert into a byte array

  • 0

I have a StringBuffer,strbuf=161656070200000000202020202001000000009E52;.

I want to convert into a byte array that looks like this:

byte[] byte_array=new byte[]
 {(byte)0x16,(byte)0x16,(byte)0x56,(byte)0x07,
  (byte)0x02,(byte)0x00,(byte)0x00,(byte)0x00,
  (byte)0x00,(byte)0x20,(byte)0x20,(byte)0x20,
  (byte)0x20,(byte)0x20,(byte)0x01,(byte)0x00,
  (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x9E,(byte)0x52};

Do I need to convert strbuf to hex string and then do getBytes()?
What is the right approach to this problem?

  • 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-26T23:54:45+00:00Added an answer on May 26, 2026 at 11:54 pm

    You can try the following.

    final String longHex = "161656070200000000202020202001000000009E52";
    byte[] bytes = new BigInteger(longHex, 16).toByteArray();
    System.out.println(Arrays.toString(bytes));
    

    prints

    [22, 22, 86, 7, 2, 0, 0, 0, 0, 32, 32, 32, 32, 32, 1, 0, 0, 0, 0, -98, 82]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem that I want to append a string into StringBuffer object
I have this code: public void readTroops() { File file = new File(resources/objects/troops.txt); StringBuffer
I have a db varchar field looks like the result of Java StringBuffer serialization:
I have a function in Java which I need to convert into php. It
I have to fetch 500K rows from the database and write that data into
I have this function here that assembles an API call to eBay. It used
I have method to covert character to haxa like private static String convert(char str)
I have worked with String, StringBuilder and StringBuffer in java. I thought of this
I have a specific format XML document that I will get pushed. This document
I have a string of text like this: This is a[WAIT] test. What I

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.